Track retained-library removals as index changes

This commit is contained in:
Sleeps
2026-10-07 13:44:50 +01:00
parent c8490cf987
commit 96c986b833
+6 -4
View File
@@ -553,6 +553,7 @@ def _index_library(
indexed = 0
skipped = 0
failed = 0
pruned = 0
current_item_ids: set[str] = set()
if progress is not None:
@@ -597,6 +598,7 @@ def _index_library(
).fetchone()
if existing:
con.execute("DELETE FROM media WHERE id = ?", (existing["id"],))
pruned += 1
shutil.rmtree(
settings.thumbs_dir / jellyfin_media_id(item_id),
ignore_errors=True,
@@ -823,11 +825,11 @@ def _index_library(
f"{summary.get('Name') or summary.get('Id')}: {exc}"
)
pruned = 0
if limit is None:
pruned = _reconcile_library(library_id, current_item_ids)
if pruned:
print(f" pruned {pruned} stale item(s) no longer present in Jellyfin")
reconciled = _reconcile_library(library_id, current_item_ids)
pruned += reconciled
if reconciled:
print(f" pruned {reconciled} stale item(s) no longer present in Jellyfin")
else:
print(" limited run: stale-item reconciliation skipped")