BUG: Incomplete filesystem scans can delete indexed media records
Maintainers usually reply within 3 days
@swastiksharma45 is already working on this.
Since Nov 21, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
No files are named, so start by tracing the folder-synchronization path in the Python backend: find where the scan is invoked, where PermissionError/OSError is caught and turned into an empty or partial file list, and the obsolete-media cleanup step that runs afterwards against the database. Read the reproduce steps as the test plan — restricted permissions on an indexed directory, then a sync. Done means an incomplete scan is distinguishable from a successful empty one, cleanup is skipped or narrowed for it, and regression tests cover permission failures and inaccessible subdirectories.
Written by the indexing model from the issue text.
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
When PictoPy encounters filesystem access errors during media scanning, such as PermissionError or other OSError exceptions, the scan may return an empty or incomplete list of media files.
The synchronization process can subsequently continue into obsolete-media cleanup, treating media that could not be inspected as missing. This can result in existing image or video records being deleted from the database even though the underlying files still exist.
This is particularly dangerous when scanning external drives, mounted directories, or libraries containing folders with restricted permissions or temporary filesystem access failures.
Steps to Reproduce
- Add a folder containing images and/or videos to PictoPy.
- Allow the initial scan to complete so that the media is indexed in the database.
- Verify that the indexed media appears in PictoPy.
- Temporarily restrict read/list permissions on the indexed directory or one of its subdirectories, or simulate a filesystem access failure.
- Trigger folder synchronization.
- Restore the original filesystem permissions.
- Check whether previously indexed media records have been removed from PictoPy despite the corresponding files still existing on disk.
Expected Behavior
- A failed or incomplete filesystem scan should not be interpreted as a successful scan containing zero media files.
- Existing indexed media records should be preserved when directories cannot be accessed or enumerated.
- Obsolete-media cleanup should only run for directories that were scanned successfully and completely.
- Temporary permission errors, unavailable external drives, and filesystem access failures should not cause indexed media or their associated metadata to be deleted.
Actual Behavior
Based on the synchronization and cleanup code paths, filesystem scan errors may be caught and converted into empty or partial scan results without reliably indicating that the scan failed.
The synchronization process can still reach obsolete-media cleanup, where media that was not discovered during the incomplete scan may be treated as deleted.
This can cause existing database records and associated data, including thumbnails and AI-generated metadata, to be removed even though the original media files have not actually been deleted.
Impact
- Existing images or videos may disappear from the PictoPy library.
- Indexed metadata may be deleted.
- AI-generated tags, face data, embeddings, and related records may be lost depending on database relationships and cleanup behavior.
- External-drive disconnections or temporary permission problems may result in unintended library data loss.
- Users may need to rescan and reprocess media to restore their library state.
Suggested Fix
- Distinguish successful, incomplete, and failed directory scans.
- Prevent obsolete-media cleanup from running against incomplete scan results.
- Preserve indexed records when filesystem access fails or the scan cannot reliably establish that media is missing.
- Make cleanup error-aware instead of treating inaccessible paths as confirmed deletions.
- Add regression tests covering permission failures, inaccessible subdirectories, failed directory enumeration, and unavailable external storage.
Record
- I agree to follow this project's Code of Conduct
- Dominant language
- Python
- Stars
- 322
- Forks
- 793
- Avg merge
- 6d 10h
- Merged PRs (30d)
- 20
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AOSSIE-Org/PictoPy
-
bug enhancement
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AOSSIE-Org/PictoPy#1802 · 2 comments ·
Maintainers usually reply within 3 days
-
BUG: XMP metadata export permanently overwrites file modification timestamp (mtime), destroying photo datesPossibly taken @swastiksharma45 claimed this 2 days ago. Openbug enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
AOSSIE-Org/PictoPy#1788 · 6 comments ·
Maintainers usually reply within 3 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
AOSSIE-Org/PictoPy#1786 · 1 comment ·
Maintainers usually reply within 3 days
-
BUG: Semantic search sees portrait phone photos sideways (SigLIP ignores EXIF orientation)Possibly taken @omkar-suryavanshi claimed this 3 days ago. Openbug enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
AOSSIE-Org/PictoPy#1780 · 5 comments ·
Maintainers usually reply within 3 days
-
BUG: Share password loses leading/trailing spaces so the password you set doesn't workPossibly taken @ManyaJain111 claimed this 2 days ago. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
AOSSIE-Org/PictoPy#1779 · 2 comments · 1 assignee ·
Maintainers usually reply within 3 days
All issues in AOSSIE-Org/PictoPy
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
hermes hooks doctor smoke test never checks the hook exit code — a crashing hook (exit=1) renders ✓ "ran clean" and "All shell hooks look healthy"Possibly taken @cestercian claimed this today. Opencomp/cli P2 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NousResearch/hermes-agent#162259 · 1 comment ·
Maintainers usually reply within 1 day
-
upstream update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
conan-io/conan-center-index#31597 ·
Maintainers usually reply within 1 day
-
community-request
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA-NeMo/Run#727 ·
Maintainers usually reply within 1 day
-
bot-triaged module: higher order operators module: pickle module: pt2-dispatcher oncall: pt2 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
pytorch/pytorch#207247 · 1 comment ·
Maintainers usually reply within 1 day