From 717e249c368fd1cc8d5c8f945c352175708691cf Mon Sep 17 00:00:00 2001 From: Caleb Allen Date: Fri, 13 Mar 2026 14:06:21 -0400 Subject: [PATCH] fix(12-02): resolve phantom tracks caused by empty library root after TOML cleanup getLibraryRoot() returned "" after DirectoryPath was removed from config.toml during multi-library migration. M3U8 relative paths could not be resolved to absolute paths, causing every playlist track to appear as phantom. Now falls back to the first library path from the database when the legacy config field is empty. --- backend/playlist/playlist.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/playlist/playlist.go b/backend/playlist/playlist.go index 5531b09..13fd7de 100644 --- a/backend/playlist/playlist.go +++ b/backend/playlist/playlist.go @@ -1169,13 +1169,24 @@ func (s *Service) playlistsDir() (string, error) { return dir, nil } -// getLibraryRoot returns the configured library directory path. +// getLibraryRoot returns the library root directory path. +// It first checks the legacy config DirectoryPath; if that is +// empty (removed during multi-library migration) it falls back +// to the first library's path from the database. func (s *Service) getLibraryRoot() string { - if s.libraryDir == nil { + if s.libraryDir != nil { + if dir := s.libraryDir.GetLibraryDirectory(); dir != "" { + return dir + } + } + + // Fallback: query the first library from the database. + libs, err := s.db.Queries.GetAllLibraries(s.db.Ctx) + if err != nil || len(libs) == 0 { return "" } - return s.libraryDir.GetLibraryDirectory() + return libs[0].Path } // savePlaylistFile saves the current state of a playlist to its