Skip to content

fix(queue): a cancel or error while merging PDFs or TIFFs no longer fails the whole job - #1648

Open
Marouane-elfadli wants to merge 5 commits into
KnifeLemon:mainfrom
Marouane-elfadli:fix/merge-job-cancel-and-errors
Open

Marouane-elfadli wants to merge 5 commits into
KnifeLemon:mainfrom
Marouane-elfadli:fix/merge-job-cancel-and-errors

Conversation

@Marouane-elfadli

Copy link
Copy Markdown
Contributor

What does this change?

RunMergedAsync ("Merge into one PDF") and RunMultiPageTiffAsync only did catch { allocator.Discard(); throw; }, so two things went wrong:

  1. Cancel: cancelling during the merge reached RunJobAsync's catch (Exception) and the job ended as Failed instead of Cancelled.
  2. Errors: anything that wasn't a 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 WriteJoinedAsync already does:

  • cancel: the output is discarded and the files become Cancelled;
  • other errors: the output is discarded and each file becomes Failed with error.conversion_failed and the exception message;
  • the TIFF path also keeps ConversionRefusedException keys on the files, as the PDF merge already did.

Only src/Filee.Core/Conversion/JobQueue.cs changes.

Type of change

  • Bug fix
  • New feature or improvement
  • New format or engine
  • Translation
  • Documentation
  • Build, CI or dependencies

How was it tested?

  • dotnet format --verify-no-changes
  • dotnet test
  • Tried it in the app (what you converted or clicked, and on which OS): merged several large PDFs and cancelled mid-merge (job shows Cancelled); merged with the output file locked (files show an error instead of failing silently).

Screenshots (UI changes)

N/A

Checklist

  • New UI strings are in all src/Filee.App/Assets/i18n/*.json files (no new UI strings; reuses error.conversion_failed)
  • New third-party code or binaries are listed in THIRD-PARTY-NOTICES.md (none added)
  • The PR does one thing (unrelated changes go in a separate PR)

@github-actions github-actions Bot added the bug Something isn't working label Nov 17, 2026

@KnifeLemon KnifeLemon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Two changes in one PR. The description says only JobQueue.cs changes, but the branch also changes PageRange.Parse, PresetEditorViewModel.Apply and SmallParsersTests. 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 only Check normalizes. Please move it into its own PR. There, the PresetEditorViewModel line isn't needed: once Parse normalizes, the stored text works as it is.

  2. Tests for the queue change. tests/Filee.Core.Tests/JobQueueTests.cs already has a RefusingMerger. Please add fakes like it for:

    • a merger that throws OperationCanceledException after the job is cancelled: job Cancelled, files Cancelled, no output left behind;
    • a merger that throws an IOException: files Failed with error.conversion_failed and the message, job Failed, no output left behind;
    • the same two for the multi-page TIFF merge (FakeTiffMerger is in FakeConverter.cs), plus a ConversionRefusedException there, which is new for TIFF.
  3. 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 an OperationCanceledException; 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants