Compare commits

...
Author SHA1 Message Date
Deluan fec03d8780 fix(scanner): check user ID instead of IsAdmin for playlist import guard
The condition `!u.IsAdmin && u.ID == ""` was wrong — with the synthetic
admin fallback (IsAdmin: true, ID: ""), it evaluated to false and
allowed playlist import with an empty OwnerID. The check should be
just `u.ID == ""` to skip whenever there's no real user.
2026-05-04 17:58:26 -04:00
Deluan 5b01636d33 Revert "fix(scanner): skip library filter for empty user ID on fresh installs"
This reverts commit 91647ed46f.
2026-05-04 17:54:42 -04:00
Deluan fda536ff17 fix(playlists): prevent playlist import when no admin user exists
Signed-off-by: Deluan <deluan@navidrome.org>
2026-05-04 17:53:44 -04:00
Deluan 91647ed46f fix(scanner): skip library filter for empty user ID on fresh installs
When no admin user exists (fresh DB), WithAdminUser falls back to
model.User{ID: ""}. The empty ID bypassed neither the invalidUserId
("-1") check nor the IsAdmin check in applyLibraryFilter, causing
Phase 3's GetTouchedAlbums to filter by user_id="" and find zero
albums. The album refresh never ran, leaving multi-disc albums with
incomplete folder_ids from Phase 1.

Fix: treat empty user ID the same as invalidUserId in
applyLibraryFilter, skipping the library filter entirely. This is
more targeted than making the fallback user admin, which would affect
other callers like Phase 4 playlist import.

Signed-off-by: Deluan <deluan@navidrome.org>
2026-05-04 17:36:24 -04:00
+1 -1
View File
@@ -50,7 +50,7 @@ func (p *phasePlaylists) produce(put func(entry *model.Folder)) error {
return nil
}
u, _ := request.UserFrom(p.ctx)
if !u.IsAdmin {
if u.ID == "" {
log.Warn(p.ctx, "Playlists will not be imported, as there are no admin users yet, "+
"Please create an admin user first, and then update the playlists for them to be imported")
return nil