Library sync on folder change - #58
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sync the Library when a folder is added or updated
What
The Library page now imports images the moment you add a folder or change a folder's path, instead of only at
make start. Each folder shows its sync progress live, and it works in both install modes (lite: SQLite, no broker; full: PostgreSQL + Celery).Removing a folder is unchanged: it only stops monitoring and never deletes images (add-only, per ADR 010).
Why
Until now, adding or repointing a folder on the Library page only updated the monitored list. Nothing was imported until the next restart, so a user could register a folder full of photos and see nothing happen, with no feedback and no obvious reason. This closes that gap: you register or repoint a folder and it syncs right away, with visible progress, while the page stays responsive even for a first import of tens of thousands of files.
How
trigger_folder_syncuse case after the folder change; removal does nothing.services/background.pyrunner) so the request never blocks. The thread lives in the web process and outlives the request, so navigating away does not stop it.SyncRunmodel records state (scanning,processing,completed,failed,interrupted), counters, and timestamps, persisted so any request can read it. The folder row polls a status endpoint over HTMX and showsScanning..., a progress bar, then a summary likeImported 36, skipped 3. A conditional unique constraint allows at most one active run per folder (which doubles as the "already syncing" guard), and counters use atomic increments with a race-safe finalize so concurrent Celery workers stay consistent.process_imageoperation and the generic image-processing task (shared with the manualimportcommand) are untouched. Aprocess_synced_imageuse case composesprocess_imagewith the progress bookkeeping; both the new Celery task and the lite thread delegate to it.sync_libraryloops over it and first marks any dangling runinterrupted, so a run killed mid-flight self-heals on the next start.Notes
make startre-syncs.docs/library_sync.md) and a new decision record added (ADR 011).