BUG: Incomplete filesystem scans can delete indexed media records

オープン
#1,752 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@swastiksharma45 がすでに取り組んでいます。

2026年11月21日 から。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
database

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

bug enhancement
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

  1. Add a folder containing images and/or videos to PictoPy.
  2. Allow the initial scan to complete so that the media is indexed in the database.
  3. Verify that the indexed media appears in PictoPy.
  4. Temporarily restrict read/list permissions on the indexed directory or one of its subdirectories, or simulate a filesystem access failure.
  5. Trigger folder synchronization.
  6. Restore the original filesystem permissions.
  7. 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
主要言語
Python
スター
322
フォーク
793
平均マージ
6日 11時間
マージ済み PR(30日)
21

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AOSSIE-Org/PictoPy のほかの issue

AOSSIE-Org/PictoPy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。