mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-08 10:40:57 +00:00
* craft-print: a job can be cancelled until it starts reaching the spooler On Windows a job asks the printer's driver for its capabilities before anything is sent. A networked printer in power save can hold that query for a long time, and an app had no way to give up on the job without risking it printing later (storytold/wordcraft#5710; CodeRabbit on storytold/wordcraft#5732). A Cancel token, passed to the new submit_cancellable, moves a job from pending to cancelled or to sending. The job checks it at the last point before anything reaches the spooler: on Windows after the driver has answered, before the job file is written; on macOS and Linux before lp starts. A cancelled job returns an error and is never sent; a job already being sent completes. submit and submit_with_progress are unchanged, and Error keeps its one variant so callers that match on it still compile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * craft-print: a job turns to sending with the provider held; the job file waits for it Review: marked as sending before it took the PrintTicket provider, a job could then wait behind another job's driver call that a sleeping printer held, and an app that waits only for jobs being sent would wait on it. The job now turns to sending only once it holds the provider, right before printing, and writes its file only after that, so a cancelled job leaves no copy of the document behind. A test-only hold in the driver call lets the Windows spooler test cancel a job while its driver doesn't answer: the cancel wins and, once the driver answers, the job stops instead of reaching the paused queue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * craft-print: the DEVMODE conversion comes before a job turns to sending CodeRabbit on #622: winprint converts the ticket to a DEVMODE, a driver call a sleeping printer can stall, before it creates the native job, so a job stalled there had already turned to sending and couldn't be cancelled. The conversion now runs first, with the provider held, while the job can still be cancelled; the provider stays held until the first copy's own conversion, so no other job comes between them. Tests: the Windows spooler test also cancels a job held in that conversion; the CUPS test gives a spooler that can't start, so any attempt to start it would change the error. README: cancellation in the progress section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * craft-print: clarify cancellation during winprint conversion repeat --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>