Skip to content

Commit ffc64af

Browse files
author
RandomEngy
committed
Fixed potential overlap of file names when batch encoding by fixing the auto-numbering system.
1 parent 9e93dfb commit ffc64af

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

VidCoder/Utilities/Utilities.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ public static string CreateUniqueFileName(string baseName, string outputDirector
213213
for (int i = 1; i < 1000; i++)
214214
{
215215
string candidateFileName = fileNameWithoutExtension + "-" + i + extension;
216-
if (!IsExcluded(candidateFileName, excludedPaths))
216+
candidateFilePath = Path.Combine(outputDirectory, candidateFileName);
217+
218+
if (!IsExcluded(candidateFilePath, excludedPaths))
217219
{
218-
candidateFilePath = Path.Combine(outputDirectory, candidateFileName);
219220
if (!File.Exists(candidateFilePath))
220221
{
221222
return candidateFilePath;

VidCoder/ViewModel/MainViewModel.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,13 +2808,15 @@ public void QueueMultiple(IEnumerable<string> filesToQueue)
28082808
return;
28092809
}
28102810

2811+
// Exclude all current queued files and the source file from the possible destinations.
2812+
HashSet<string> excludedPaths = this.GetQueuedFiles();
2813+
28112814
var itemsToQueue = new List<EncodeJobViewModel>();
28122815
foreach (string fileToQueue in filesToQueue)
28132816
{
2814-
// Exclude all current queued files and the source file from the possible destinations.
2815-
HashSet<string> excludedPaths = this.GetQueuedFiles();
2816-
excludedPaths.Add(fileToQueue);
2817+
excludedPaths.Add(fileToQueue.ToLowerInvariant());
28172818
string queueOutputPath = Utilities.CreateUniqueFileName(Path.GetFileNameWithoutExtension(fileToQueue) + this.GetOutputExtensionForCurrentEncodingProfile(), Settings.Default.AutoNameOutputFolder, excludedPaths);
2819+
excludedPaths.Add(queueOutputPath.ToLowerInvariant());
28182820

28192821
// When ChapterStart is 0, this means the whole title is encoded.
28202822
var job = new EncodeJob

0 commit comments

Comments
 (0)