Repository navigation
fix(queue): a cancel or error while merging PDFs or TIFFs no longer fails the whole job - #1648
Marouane-elfadli wants to merge 5 commits into
Conversation
KnifeLemon
left a comment
There was a problem hiding this comment.
Thanks, @Marouane-elfadli! The queue part is right: RunMergedAsync and RunMultiPageTiffAsync were the merge paths that still rethrew, so a cancel during the merge ended up in RunJobAsync's catch (Exception) as a failed job, and other errors left no message on the files. Handling it the way WriteJoinedAsync does is the right fix.
A few things before we can merge:
-
Two changes in one PR. The description says only
JobQueue.cschanges, but the branch also changesPageRange.Parse,PresetEditorViewModel.ApplyandSmallParsersTests. The page-range part is a real fix too: a range typed into a preset with an en dash (2–5) is read as every page today, since onlyChecknormalizes. Please move it into its own PR. There, thePresetEditorViewModelline isn't needed: onceParsenormalizes, the stored text works as it is. -
Tests for the queue change.
tests/Filee.Core.Tests/JobQueueTests.csalready has aRefusingMerger. Please add fakes like it for:- a merger that throws
OperationCanceledExceptionafter the job is cancelled: jobCancelled, filesCancelled, no output left behind; - a merger that throws an
IOException: filesFailedwitherror.conversion_failedand the message, jobFailed, no output left behind; - the same two for the multi-page TIFF merge (
FakeTiffMergeris inFakeConverter.cs), plus aConversionRefusedExceptionthere, which is new for TIFF.
- a merger that throws
-
Only a real cancel counts as one. Please use
catch (OperationCanceledException) when (job.CancellationToken.IsCancellationRequested)in both methods. A timeout inside a merger is also anOperationCanceledException; with the filter it falls through to the error branch, instead of showing the files as Cancelled under a failed job.
CI: the three red checks aren't from this PR: a temp file still locked in UpscalerTests (win-x64), MemoryTrimmerTests (linux-arm64), and the arm64 package step that needs that build. They'll run again on your next push.
The test boxes in the description are unchecked; please run dotnet format --verify-no-changes and dotnet test tests/Filee.Core.Tests before pushing.
What does this change?
RunMergedAsync("Merge into one PDF") andRunMultiPageTiffAsynconly didcatch { allocator.Discard(); throw; }, so two things went wrong:RunJobAsync'scatch (Exception)and the job ended asFailedinstead ofCancelled.ConversionRefusedException(disk full, locked output file, a PDF the merger can't read) failed the whole job with no per-file error, so the files stayed Pending or Done with no message.Both methods now handle this the way
WriteJoinedAsyncalready does:Cancelled;Failedwitherror.conversion_failedand the exception message;ConversionRefusedExceptionkeys on the files, as the PDF merge already did.Only
src/Filee.Core/Conversion/JobQueue.cschanges.Type of change
How was it tested?
dotnet format --verify-no-changesdotnet testScreenshots (UI changes)
N/A
Checklist
src/Filee.App/Assets/i18n/*.jsonfiles (no new UI strings; reuseserror.conversion_failed)THIRD-PARTY-NOTICES.md(none added)