BUG: Replacing an image at the same path retains stale AI metadata

Aperta
#1,753 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@risingsamurai ci sta già lavorando.

Dal 20/11/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, database

Direzione di ricerca

Start from the folder-synchronization code that detects a changed file and prepares the updated image record, then follow it into the database upsert keyed on the image path. Check which fields the upsert preserves — particularly isTagged, isEmbedded, GPS and the related tag/face/embedding records — and decide what must be reset or deleted when content changes. Reproduce by adding an image, letting AI processing finish, replacing the file at the same path, and re-running sync; done means fresh processing is scheduled and a regression test covers the same-path replacement.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug enhancement
Is there an existing issue for this?
  • I have searched the existing issues
What happened?

When an existing image is replaced with different image content at the same filesystem path, PictoPy may retain the previous image's AI-generated metadata and processing state.

The synchronization logic detects the changed file and prepares an updated image record. However, when the database performs an upsert using the existing image path, the existing record's ID and AI-processing flags may be retained instead of being reset for the new content.

Consequently, the replacement image may continue using the previous image's tags, embeddings, face information, or semantic metadata, and may not be scheduled for fresh AI processing.

Steps to Reproduce

  1. Add an image to PictoPy.
  2. Allow AI tagging and embedding generation to finish.
  3. Record the image's existing AI tags and processing state.
  4. Replace the image file with completely different content while keeping the same filename and filesystem path.
  5. Trigger folder synchronization.
  6. Inspect the updated image record and its associated AI data.
  7. Verify whether the replacement image receives fresh AI processing.

Expected Behavior

When PictoPy detects that image content has changed:

  • The previous content's AI-generated metadata should not be associated with the replacement image.
  • Relevant AI-processing flags should be reset.
  • Old tags, face records, and embeddings associated with the previous content should be invalidated or replaced.
  • The replacement image should be scheduled for fresh AI processing.
  • Metadata such as GPS coordinates should reflect the replacement file rather than retain stale values.

Actual Behavior

The database upsert appears to preserve the existing image identity and AI-processing flags when a record with the same path already exists.

In particular, existing isTagged and isEmbedded values may remain true even when the image content has changed.

This can prevent the replacement image from entering normal AI-processing pipelines, while existing AI-generated metadata and related records remain associated with the image's database identity.

As a result, the gallery, tagging, face-related data, or semantic search may continue reflecting the original image instead of the replacement content.

Impact

  • Incorrect AI tags may remain attached to replaced images.
  • Face-related metadata may describe the previous image.
  • Image embeddings may represent outdated content.
  • Semantic search may return results based on the previous image.
  • Replacement images may be skipped by AI-processing queues if their flags indicate that processing has already completed.

Suggested Fix

When a same-path image replacement is detected:

  • Update or invalidate content-dependent AI metadata.
  • Reset AI-processing flags so the replacement is processed again.
  • Remove or regenerate stale embeddings, face records, and semantic metadata.
  • Ensure GPS and other file-derived metadata are updated correctly, including clearing values that are no longer present.
  • Add regression tests for replacing an already-processed image with different content at the same path.
Record
  • I agree to follow this project's Code of Conduct
Lingua principale
Python
Stelle
322
Fork
793
Merge medio
6g 9h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AOSSIE-Org/PictoPy

Tutte le issue di AOSSIE-Org/PictoPy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.