fix: synchronize database records with filesystem deletions
All checks were successful
Docker Build / build (push) Successful in 12s

This commit is contained in:
wander 2026-03-08 06:19:08 -04:00
parent a296c932f7
commit 6e0d081799

View file

@ -1283,7 +1283,13 @@ def api_recovery_delete_batch():
p.unlink()
log(f"🗑️ Deleted target: {path}")
# 3. Cleanup empty parent
# 3. Synchronize Database (Remove orphaned record)
with get_db() as conn:
conn.execute("DELETE FROM videos WHERE symlink = ?", (path,))
conn.commit()
log(f"💾 [SYNC] Removed DB record for: {path}")
# 4. Cleanup empty parent
parent = p.parent
if parent != Path(TARGET_DIR) and parent != Path(HIDDEN_DIR):
if parent.exists() and not any(parent.iterdir()):
@ -1396,6 +1402,8 @@ def api_recovery_delete():
if vid_id:
with get_db() as conn:
conn.execute("DELETE FROM lost_media WHERE video_id = ?", (vid_id,))
# Also remove from main videos table if present
conn.execute("DELETE FROM videos WHERE symlink = ?", (filepath,))
conn.commit()
log(f"🗑️ Deleted file: {filepath}")