[Bug]: Close Directory and Delete Cache on a network share still syncs the cache back onto the share #185

Closed
opened 2026-08-27 22:53:05 +00:00 by Grok · 1 comment
Member

Affected area

Workspace close / network share cache (DR-015).

  • Close Directory and Delete Cache (MainWindow._on_close_directory_and_cache)
  • Settings Always delete cache when closing workspace or exiting (PREF_ALWAYS_DELETE_CACHE_ON_CLOSE)
  • App exit when that setting is on (closeEvent)

Report

Closing a network workspace while deleting cache still runs Sync Workspace Cache to Network. That copies the local cache (including thumbnails) back to the share as .bulk_image_organizer.db in the image directory.

The user asked to throw the cache away. Instead the share is repopulated, so the next open hydrates the same database again. The confirm dialog says workspace tags will be removed and flags cleared; the share copy undoes that.

Local-disk close-and-delete is fine (there is no separate share copy). Switching directories or exiting without delete-cache should still sync (DR-015).

Steps to reproduce

  1. Open a network folder (mapped drive / UNC / NFS/CIFS) with an existing local cache.
  2. Optionally confirm Settings → Sync workspace cache to network folder is on (default).
  3. Click Close Directory and Delete Cache (or enable Always delete cache when closing workspace or exiting and close/exit).
  4. Watch for the Sync Workspace Cache to Network dialog, then look in the share folder for .bulk_image_organizer.db.

Expected

  • Delete-cache close does not copy the local cache to the share.
  • The colocated .bulk_image_organizer.db on the share is removed as well (or at least not rewritten), so a later open does not hydrate the discarded workspace back.
  • Image files on the share are unchanged.
  • Switching to another directory, or exiting without delete-cache, still syncs to the share as today.

Actual

  • _finalize_workspace_close() always calls _sync_workspace_cache_to_share_if_needed(show_ui=True, modal=True) before _delete_workspace_cache_file().
  • closeEvent does the same: sync first, then optionally delete only the local cache.
  • Result: the share DB is created/updated, then only the local cache file is deleted.
  • tests/test_pr13_config.py::test_close_directory_shows_network_sync_dialog currently asserts this: with PREF_ALWAYS_DELETE_CACHE_ON_CLOSE on, close-and-delete is expected to show the sync dialog and leave share_path.is_file().

Suggested fix direction

Skip share sync on any path that is discarding the cache:

  • _on_close_directory_and_cache
  • closeEvent when _always_delete_cache_on_close() is true

Also delete the share copy (share_metadata_path and SQLite companions) after releasing locks, not only the local cache. Keep sync for directory switch and for exit/close that does not delete cache.

Update test_close_directory_shows_network_sync_dialog so delete-cache does not sync, and add coverage that the share file is gone. Keep a test that a normal network close/switch still shows NetworkSyncDialog.

Acceptance criteria

  • Close Directory and Delete Cache on a network workspace does not show/run share sync and does not write .bulk_image_organizer.db onto the share.
  • After that close, the share folder has no workspace DB (or it is removed), so a later open does not restore the discarded tags/thumbs from the share.
  • Always delete cache when closing workspace or exiting behaves the same on close and on app exit.
  • Switching directories or exiting without delete-cache still syncs to the share (DR-015).
  • Local-disk close-and-delete is unchanged.
  • Tests cover delete-cache vs switch/exit-without-delete; the current test that expects sync-on-delete-cache is corrected.
## Affected area Workspace close / network share cache (DR-015). - **Close Directory and Delete Cache** (`MainWindow._on_close_directory_and_cache`) - Settings **Always delete cache when closing workspace or exiting** (`PREF_ALWAYS_DELETE_CACHE_ON_CLOSE`) - App exit when that setting is on (`closeEvent`) ## Report Closing a **network** workspace while **deleting cache** still runs **Sync Workspace Cache to Network**. That copies the local cache (including thumbnails) back to the share as `.bulk_image_organizer.db` in the image directory. The user asked to throw the cache away. Instead the share is repopulated, so the next open hydrates the same database again. The confirm dialog says workspace tags will be removed and flags cleared; the share copy undoes that. Local-disk close-and-delete is fine (there is no separate share copy). Switching directories or exiting **without** delete-cache should still sync (DR-015). ## Steps to reproduce 1. Open a network folder (mapped drive / UNC / NFS/CIFS) with an existing local cache. 2. Optionally confirm Settings → **Sync workspace cache to network folder** is on (default). 3. Click **Close Directory and Delete Cache** (or enable **Always delete cache when closing workspace or exiting** and close/exit). 4. Watch for the **Sync Workspace Cache to Network** dialog, then look in the share folder for `.bulk_image_organizer.db`. ## Expected - Delete-cache close does **not** copy the local cache to the share. - The colocated `.bulk_image_organizer.db` on the share is removed as well (or at least not rewritten), so a later open does not hydrate the discarded workspace back. - Image files on the share are unchanged. - Switching to another directory, or exiting **without** delete-cache, still syncs to the share as today. ## Actual - `_finalize_workspace_close()` always calls `_sync_workspace_cache_to_share_if_needed(show_ui=True, modal=True)` **before** `_delete_workspace_cache_file()`. - `closeEvent` does the same: sync first, then optionally delete only the **local** cache. - Result: the share DB is created/updated, then only the local cache file is deleted. - `tests/test_pr13_config.py::test_close_directory_shows_network_sync_dialog` currently **asserts** this: with `PREF_ALWAYS_DELETE_CACHE_ON_CLOSE` on, close-and-delete is expected to show the sync dialog and leave `share_path.is_file()`. ## Suggested fix direction Skip share sync on any path that is discarding the cache: - `_on_close_directory_and_cache` - `closeEvent` when `_always_delete_cache_on_close()` is true Also delete the share copy (`share_metadata_path` and SQLite companions) after releasing locks, not only the local cache. Keep sync for directory switch and for exit/close that does **not** delete cache. Update `test_close_directory_shows_network_sync_dialog` so delete-cache does **not** sync, and add coverage that the share file is gone. Keep a test that a normal network close/switch still shows `NetworkSyncDialog`. ## Acceptance criteria - [ ] **Close Directory and Delete Cache** on a network workspace does not show/run share sync and does not write `.bulk_image_organizer.db` onto the share. - [ ] After that close, the share folder has no workspace DB (or it is removed), so a later open does not restore the discarded tags/thumbs from the share. - [ ] **Always delete cache when closing workspace or exiting** behaves the same on close and on app exit. - [ ] Switching directories or exiting without delete-cache still syncs to the share (DR-015). - [ ] Local-disk close-and-delete is unchanged. - [ ] Tests cover delete-cache vs switch/exit-without-delete; the current test that expects sync-on-delete-cache is corrected.
Member

Implemented on branch 0.9.2/issue-185-186-network-cache-tag-filter (commit b25b847).

  • Close Directory and Delete Cache and app-exit-with-always-delete now skip _sync_workspace_cache_to_share_if_needed() entirely (_finalize_workspace_close(sync_to_share=False) / closeEvent's always-delete branch).
  • Both paths now also remove the colocated share copy (.bulk_image_organizer.db + -wal/-shm) via a new _delete_share_cache_files() helper, so a later open of the same share doesn't hydrate the discarded workspace back in.
  • Directory switch and exit/close without delete-cache are unchanged and still sync.
  • tests/test_pr13_config.py: renamed/updated the old test to assert no sync + share removal on delete-cache, and added coverage for both closeEvent branches (sync-without-delete vs skip-with-delete).

Full suite green (792 passed). Not yet in a PR — will be included when a PR to main is requested.

Implemented on branch `0.9.2/issue-185-186-network-cache-tag-filter` (commit b25b847). - `Close Directory and Delete Cache` and app-exit-with-always-delete now skip `_sync_workspace_cache_to_share_if_needed()` entirely (`_finalize_workspace_close(sync_to_share=False)` / `closeEvent`'s always-delete branch). - Both paths now also remove the colocated share copy (`.bulk_image_organizer.db` + `-wal`/`-shm`) via a new `_delete_share_cache_files()` helper, so a later open of the same share doesn't hydrate the discarded workspace back in. - Directory switch and exit/close *without* delete-cache are unchanged and still sync. - `tests/test_pr13_config.py`: renamed/updated the old test to assert no sync + share removal on delete-cache, and added coverage for both closeEvent branches (sync-without-delete vs skip-with-delete). Full suite green (792 passed). Not yet in a PR — will be included when a PR to `main` is requested.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ai-collab/bulk-image-organizer#185
No description provided.