Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Fix job queue busy counter, progress dilution, and watch folder cache limits
gtxPrime0afcc1ed5442
diff --git a/src/Filee.Core/Conversion/ConversionJob.cs b/src/Filee.Core/Conversion/ConversionJob.csindex fcd1f06c..f14c218e 100644--- a/src/Filee.Core/Conversion/ConversionJob.cs+++ b/src/Filee.Core/Conversion/ConversionJob.cs@@ -66,8 +66,18 @@ public sealed class ConversionJobpublic IReadOnlyList<FileResult> Files { get; }public JobState State { get; internal set; } = JobState.Queued;- /// <summary>Overall progress 0..1.</summary>- public double Progress => Files.Count == 0 ? 1 : Files.Average(f => f.Progress);+ /// <summary>Overall progress 0..1: counts completed files as full and sums partial progress of running ones,+ /// so files still waiting at 0 don't dilute the displayed percentage.</summary>+ public double Progress+ {+ get+ {+ if (Files.Count == 0) return 1;+ var done = Files.Count(f => f.State is FileState.Done or FileState.Skipped or FileState.Failed or FileState.Cancelled);+ var partialSum = Files.Where(f => f.State == FileState.Running).Sum(f => f.Progress);+ return (done + partialSum) / Files.Count;+ }+ }/// <summary>Every file written by the job.</summary>public IEnumerable<string> Outputs => Files.SelectMany(f => f.Outputs);diff --git a/src/Filee.Core/Conversion/JobQueue.cs b/src/Filee.Core/Conversion/JobQueue.csindex 7230fb5a..7d866c70 100644--- a/src/Filee.Core/Conversion/JobQueue.cs+++ b/src/Filee.Core/Conversion/JobQueue.cs@@ -514,6 +514,9 @@ public sealed class JobQueue : IAsyncDisposable{await foreach (var job in _channel.Reader.ReadAllAsync()){+ // NOTE: _busy was incremented by Enqueue before the job was written to the channel.+ // Do NOT call RunAsync here — it has its own increment/decrement for external callers+ // (tests, CLI). Calling it would double-increment and triple-decrement _busy.try{if (job.CancellationToken.IsCancellationRequested)@@ -523,7 +526,7 @@ public sealed class JobQueue : IAsyncDisposableJobFinished?.Invoke(this, job);continue;}- await RunAsync(job);+ await RunJobAsync(job);}finally{diff --git a/src/Filee.Core/Watching/FileNameFilter.cs b/src/Filee.Core/Watching/FileNameFilter.csindex f91f9275..bdd032ea 100644--- a/src/Filee.Core/Watching/FileNameFilter.cs+++ b/src/Filee.Core/Watching/FileNameFilter.cs@@ -60,6 +60,8 @@ public sealed class FileNameFilter{if (patterns is null || patterns.Count == 0)return All;+ if (Cache.Count > 256)+ Cache.Clear();return Cache.GetOrAdd(string.Join('\n', patterns), _ =>{var regexes = new List<Regex>();diff --git a/src/Filee.Core/Watching/FolderWatcher.cs b/src/Filee.Core/Watching/FolderWatcher.csindex 86149b4c..6c6df318 100644--- a/src/Filee.Core/Watching/FolderWatcher.cs+++ b/src/Filee.Core/Watching/FolderWatcher.cs@@ -146,6 +146,8 @@ public sealed class FolderWatcher : IAsyncDisposablecontinue;_pending.TryRemove(path, out _);// A file that was converted before (same size and time) is not converted again.+ if (_handled.Count > 10_000)+ _handled.Clear();if (_handled.Add(current.Key(path)))ready.Add(path);}@@ -230,9 +232,23 @@ public sealed class FolderWatcher : IAsyncDisposableDirectory.CreateDirectory(Path.GetDirectoryName(target)!);var name = Path.GetFileNameWithoutExtension(target);var extension = Path.GetExtension(target);- for (var n = 2; File.Exists(target); n++)- target = Path.Combine(Path.GetDirectoryName(target)!, $"{name} ({n}){extension}");- File.Move(source, target);+ for (var n = 2; ; n++)+ {+ if (File.Exists(target))+ {+ target = Path.Combine(Path.GetDirectoryName(target)!, $"{name} ({n}){extension}");+ continue;+ }+ try+ {+ File.Move(source, target);+ break;+ }+ catch (IOException) when (File.Exists(target) && n < 100)+ {+ target = Path.Combine(Path.GetDirectoryName(target)!, $"{name} ({n}){extension}");+ }+ }}catch (Exception ex) when (ex is IOException or UnauthorizedAccessException){