You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
🟠Catalog: purge-virtual orphan cleanup deletes nothing — NOT IN vs NULL content_id #2
The admin "purge virtual items" action deletes the aiostreams:// file rows but then deletes zero orphaned catalog items, because its orphan query uses NOT IN against a subquery that can contain NULL. Every purged title stays in the catalog as a permanent ghost entry with no files.
resItems, err:=tx.Exec(ctx, ` DELETE FROM media_items WHERE content_id NOT IN (SELECT DISTINCT content_id FROM media_files)`)
What goes wrong
media_files.content_id is nullable, and NULL rows exist in normal operation — the scanner's own unmatched query filters on mf.content_id IS NULL (file_repo.go:1959). In SQL, x NOT IN (subquery) evaluates to UNKNOWN (never true) for every row as soon as the subquery yields a single NULL. So whenever even one unmatched media file exists anywhere in the DB, step 2 deletes nothing, and step 3's collection-link cleanup consequently has nothing to clean. The endpoint reports success while leaving ghost items behind.
Suggested fix
Either filter NULLs inside the subquery:
WHERE content_id NOT IN (SELECT content_id FROM media_files WHERE content_id IS NOT NULL)
or (preferred) rewrite as NOT EXISTS, which has sane NULL semantics:
DELETEFROM media_items mi
WHERE NOT EXISTS (SELECT1FROM media_files mf WHEREmf.content_id=mi.content_id)
Filed from an automated multi-agent audit of this branch; finding verified against the code at the cited commit.
Fixed in commit 40a2a2b: rewritten PurgeVirtualPlaybackItems query to use NOT EXISTS (SELECT 1 FROM media_files mf WHERE mf.content_id = mi.content_id) to properly delete orphaned items when NULL content_id rows exist.
Activity
drondeseries commentedon Jul 23, 2026
Fixed in commit 40a2a2b: rewritten PurgeVirtualPlaybackItems query to use NOT EXISTS (SELECT 1 FROM media_files mf WHERE mf.content_id = mi.content_id) to properly delete orphaned items when NULL content_id rows exist.
feat(web): add Connect Apps settings page for compat sign-in (#488)