fix(dispatch): clean up transient library upload from Direct-Print flow (#730)

The "Print" button on a printer card (and drag-drop-onto-card) used
  FileUploadModal to persist the file as a LibraryFile, then dispatched
  through POST /library/files/{id}/print. The LibraryFile row + disk file
  were left behind after every one-off print, polluting File Manager with
  entries the user never asked to save.

  FilePrintRequest.cleanup_library_after_dispatch (default False) opts
  into post-dispatch cleanup. When set, _run_print_library_file stages
  db.delete(lib_file) in the same transaction as archive_print so a
  mid-flight FTP / start_print failure rolls both back cleanly, commits
  together, then unlinks the library disk file + thumbnail after commit
  succeeds. External library files (is_external=True) are never touched.

  Only the Printers-page Direct-Print PrintModal sets the flag. Every
  other api.printLibraryFile caller (File Manager Print, Project Detail
  Print) leaves it unset — their entries are there by user intent.

  Also moves formatPrintName out of PrintersPage.tsx into a new
  utils/printName.ts module — fa1c46d9 (#881) exported it inline so its
  test could import it, tripping react-refresh/only-export-components.
This commit is contained in:
maziggy
2026-04-21 14:10:04 +02:00
parent 276a1db3ef
commit 1682b6956f
15 changed files with 420 additions and 159 deletions
+1
View File
@@ -4645,6 +4645,7 @@ export const api = {
timelapse?: boolean;
use_ams?: boolean;
project_id?: number;
cleanup_library_after_dispatch?: boolean;
}
) =>
request<BackgroundDispatchResponse>(