[Bug]: Cancelling a directory scan while opening a remote directory does not stop promptly #177
Labels
No labels
Kind/Bug
Kind/Feature
Priority/High
Priority/Medium
Reviewed/Confirmed
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ai-collab/bulk-image-organizer#177
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
App version
0.8.0+adhoc.dupe.compare.progress Beta(development branch0.8.0/dupe-compare-progress, VERSION0.8.0-adhoc.dupe-compare-progress).Report
Observed while opening a remote (network) directory and cancelling the directory scan on the build above.
Opening a network folder is a multi-stage flow on this branch: hydrate the local workspace cache from the share (
NetworkHydrateDialog, with its own Cancel), then a main-thread “Preparing workspace…” preload, then the background directory scan (Discovering / Reading Metadata) whose toolbar control is Cancel Scan.Cancel during that open is not a prompt, clean abort. The scan (or the open) continues to do remote I/O for a long time after Cancel, and the UI stays in a cancelling/in-progress state instead of returning to idle.
Steps to reproduce
0.8.0+adhoc.dupe.compare.progress Beta.Expected
_scan_in_progress.Actual
Cancel during a remote-directory open does not stop the work promptly. The open/scan keeps running against the share after the user has asked it to stop.
Notes from the 0.8.0 branch (not a substitute for a second repro)
These are the points in
open_directory()/ scan cancel on0.8.0/dupe-compare-progressthat would produce this on a slow share:predict_hydrate_action()runs with no cancel poll. That call does blocking sharestat/ DB reads. Cancel on the dialog cannot interrupt it.prepare_network_workspace_cache()only getsshould_continueon thecopiedpath. The non-copy branch (merge/ already-current cache) ignores the dialog Cancel until later merge import (if any)._scan_in_progressis set only in_launch_directory_scan(). The “Preparing workspace…” preload (fullget_all_images, tag dicts,get_thumbnail_blob_dicts) runs on the main thread. Same silent gap as issue #176; there is no cancel control during it._on_cancel_scan()only setsScanWorker._cancelled. Discovery pollsis_cancelledbetweenscan_directory()yields; a slowos.scandir/staton the share is not interrupted. Metadata enrichment waits onMetadataScanContext.is_discovery_complete()(50 ms poll) and then finishes in-flightThreadPoolExecutorchunks that may be reading remote files. The toolbar stays on Cancel Scan until_on_deep_finished._on_deep_finished: image count, recent-dir write) even whensummary["cancelled"]is true. Share sync is skipped on cancel, which is correct; the finalize pause is not.Related: #176 (silent freeze between hydrate dialog close and grid populate on this same branch). This issue is specifically cancel during a remote open/scan, not the missing progress after hydrate.
Acceptance criteria
_abort_network_hydratecontract)._scan_in_progress.Fixed on branch
0.9.1/issue-176-178-scan-freeze(commit6dc8b7a), building on the #176 fix:predict_hydrate_action()now runs via a backgroundThreadPoolExecutorwhileopen_directory()polls the hydrate dialog's Cancel state instead of blocking the main thread on that single uninterruptible stat()/SELECT call. On cancel, the open aborts immediately (HydrateCancelled) without waiting for the background call to return — its read-only result is simply discarded whenever it arrives._scan_in_progressis now set (and the toolbar updated) as soon as the post-hydrate preload phase starts, with a new_open_cancel_requestedflag so_on_cancel_scan()can signal cancellation before a real scan worker exists yet — checked at each safe point in the preload block via_preload_cancel_checkpoint(). Cancel Scan is now available for the whole open, not just after discovery/enrichment starts.scan_metadata_ordered_and_upsert()'sThreadPoolExecutornow checksis_cancelled()between each already-completed future in a chunk (not just after the whole chunk drains) and shuts down withwait=False, cancel_futures=Trueinstead of thewithblock's implicitwait=True— cancel no longer waits for an in-flight remote decode that's still running when it fires._on_deep_finished()skips theget_image_count()/add_recent_dir()round trip on a cancelled scan, matching the existing skip of prune/dupe/sync for that case.Acceptance criteria from the report are covered: cancel during hydrate leaves no directory open, Cancel Scan during discovery/enrichment doesn't wait for in-flight remote decodes, the UI returns to idle either way, and a subsequent Open Directory isn't blocked. Local-directory cancel behavior is unchanged (same code paths, cancel just checked more often). New tests added in
tests/test_pr13_config.pyandtests/test_image_scanner.py(including one that deliberately regresses the fix to confirm the test actually catches it), full suite passing. Not closing yet — development branch, not yet merged tomain.Closing — fixed via PR #187 (branch
0.9.1/issue-176-178-scan-freeze).