diff --git a/internal/storage/face_gallery_repo.go b/internal/storage/face_gallery_repo.go index 5e62bc5..635016d 100644 --- a/internal/storage/face_gallery_repo.go +++ b/internal/storage/face_gallery_repo.go @@ -112,6 +112,11 @@ func (r *FaceGalleryRepo) AddPhoto(personID int, photoPath string) error { return err } defer db.Close() + // Skip if already exists + var existing int + if db.QueryRow(`SELECT COUNT(*) FROM face_photos WHERE person_id = ? AND photo_path = ?`, personID, photoPath).Scan(&existing) == nil && existing > 0 { + return nil + } now := time.Now().Format(time.RFC3339) _, err = db.Exec(`INSERT INTO face_photos(person_id, photo_path, created_at) VALUES(?, ?, ?)`, personID, photoPath, now) return err