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.
This commit is contained in:
2026-03-13 14:06:21 -04:00
parent 1ad099a9d3
commit 717e249c36
+14 -3
View File
@@ -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