Skip to content

Remove an album's photomap_index folder when the album is deleted - #435

Merged
lstein merged 2 commits into
masterfrom
lstein/fix/delete-album-index-dir
Nov 14, 2026
Merged

lstein merged 2 commits into
masterfrom
lstein/fix/delete-album-index-dir

Conversation

@lstein

@lstein lstein commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Fixes #433.

Problem

Deleting a directory album left its photomap_index folder (embeddings, UMAP cache, thumbnails, scan bookkeeping) behind inside the user's photo folder. Only InvokeAI-board albums had their derived index directory cleaned up.

Fix

DELETE /delete_album/{key} now removes the album's index directory, under these rules:

  • Only folders PhotoMap chose: a directory named photomap_index (the name the album form fills in) or the board album's per-user index dir. Custom index locations and symlinked index folders are left alone. Photos are never touched.
  • Shared folders are kept while any remaining album still uses them, compared with os.path.samefile. Comparing path strings misses case-insensitive spellings on macOS and bind mounts.
  • Refused (409) while the album is being indexed. The scan, UMAP fit and final save never check the cancel flag, and saving recreates the parent directory, so cancel-and-delete would leave a fresh orphan photomap_index.
  • rmtree runs off the event loop, since a thumbnail directory can be large or on a network share.
  • An unknown album key now returns 404 instead of a 500 that wrapped the 404.

Frontend: the delete confirmation says the search index is removed too and photos are not touched. A failed delete shows the server's reason via errorDetail(). The utils.js mocks in five Jest suites gained errorDetail accordingly.

Testing

  • New tests/backend/test_delete_album_index.py covers: removal; a shared index kept until its last user is deleted; custom location untouched; 409 while indexing; never-indexed album; unknown album 404; a second spelling (symlinked parent) of a shared folder.
  • Full backend suite (1358 passed) and Jest (1044 passed); ruff, eslint and prettier are clean.
  • An adversarial review found the string-compare and in-flight-indexing problems; both are fixed here.
  • Tested manually by the author.

🤖 Generated with Claude Code

lstein and others added 2 commits November 14, 2026 12:50
Deleting a directory album left its photomap_index folder (embeddings,
UMAP cache, thumbnails) behind in the photo folder; only InvokeAI-board
albums had their index directory cleaned up. Fixes #433.

- Only a folder PhotoMap chose is removed: one named photomap_index, or
  the board album's per-user index directory. Custom index locations and
  symlinked index folders are left alone; photos are never touched.
- The folder is kept while another album still uses it, compared by
  os.path.samefile so case-insensitive (macOS) or bind-mount spellings of
  the same folder are recognised.
- Deleting an album that is being indexed is refused with 409: the scan,
  UMAP fit and final save never check the cancel flag and would recreate
  the folder after it was removed.
- rmtree runs off the event loop; an unknown album now gets 404 rather
  than a 500 wrapping it.
- The delete confirmation says the index goes too, and a failed delete
  shows the server's reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lstein
lstein enabled auto-merge (squash) November 14, 2026 18:03
@lstein
lstein merged commit f77b44c into master Nov 14, 2026
11 checks passed
@lstein
lstein deleted the lstein/fix/delete-album-index-dir branch November 14, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Photomap_index folder

1 participant