fixed shit with the renames
This commit is contained in:
+3
-43
@@ -2,7 +2,6 @@ using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -78,42 +77,6 @@ public partial class MainWindow : FluentWindow
|
||||
|
||||
// ── Helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// If the file's parent folder has a bracketed prefix (e.g. "[neoHEVC] ")
|
||||
/// and the file itself doesn't, renames the file on disk to include that
|
||||
/// prefix and returns the new path. Returns the original path unchanged if
|
||||
/// the condition isn't met or the rename fails.
|
||||
/// </summary>
|
||||
private static string TryApplyFolderPrefix(string filePath)
|
||||
{
|
||||
string? folder = Path.GetDirectoryName(filePath);
|
||||
if (string.IsNullOrEmpty(folder)) return filePath;
|
||||
|
||||
string folderName = Path.GetFileName(folder);
|
||||
var match = Regex.Match(folderName, @"^\[.+?\] ");
|
||||
if (!match.Success) return filePath;
|
||||
|
||||
string prefix = match.Value;
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
|
||||
if (fileName.StartsWith(prefix, StringComparison.Ordinal)) return filePath;
|
||||
|
||||
string newFileName = prefix + fileName;
|
||||
string newFilePath = Path.Combine(folder, newFileName);
|
||||
|
||||
if (File.Exists(newFilePath)) return filePath;
|
||||
|
||||
try
|
||||
{
|
||||
File.Move(filePath, newFilePath);
|
||||
return newFilePath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
|
||||
private static void RestartApplication()
|
||||
{
|
||||
try
|
||||
@@ -249,23 +212,20 @@ public partial class MainWindow : FluentWindow
|
||||
&& !_fileQueue.Any(q => string.Equals(q.FilePath, p, StringComparison.OrdinalIgnoreCase)))
|
||||
.ToList();
|
||||
|
||||
var addedPaths = new List<string>();
|
||||
foreach (var path in newFiles)
|
||||
{
|
||||
string effectivePath = TryApplyFolderPrefix(path);
|
||||
var item = new QueuedFileItem(effectivePath);
|
||||
var item = new QueuedFileItem(path);
|
||||
item.PropertyChanged += QueuedFileItem_PropertyChanged;
|
||||
_fileQueue.Add(item);
|
||||
_ = ScanFileItemAsync(item);
|
||||
addedPaths.Add(effectivePath);
|
||||
}
|
||||
|
||||
UpdateLoadingOverlay();
|
||||
|
||||
if (addedPaths.Count > 0)
|
||||
if (newFiles.Count > 0)
|
||||
{
|
||||
var first = _fileQueue.FirstOrDefault(q =>
|
||||
string.Equals(q.FilePath, addedPaths[0], StringComparison.OrdinalIgnoreCase));
|
||||
string.Equals(q.FilePath, newFiles[0], StringComparison.OrdinalIgnoreCase));
|
||||
if (first != null) FileQueueList.SelectedItem = first;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user