mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-15 05:47:13 +02:00
fix: address race conditions and design issues in PlaylistGenerator
Rename PlaylistInfo.OwnerUserID to OwnerUsername so plugins provide usernames instead of internal user IDs, with server-side resolution via FindByUsername. Fix race condition on playlistGenerators map by using write lock in startPlaylistGenerators and moving map access inside the lock in unloadPlugin/Stop. Add context and WaitGroup to the orchestrator for proper cancellation and goroutine tracking. Include owner_id in the plugin playlist unique index. Use SetTracks instead of direct assignment to refresh playlist duration/size/song count stats.
This commit is contained in:
parent
188584e3fb
commit
a8a336de33
10 changed files with 71 additions and 42 deletions
12
plugins/testdata/test-playlist-generator/main.go
vendored
12
plugins/testdata/test-playlist-generator/main.go
vendored
|
|
@ -21,16 +21,16 @@ func (t *testPlaylistGenerator) GetPlaylists(_ pg.GetPlaylistsRequest) (pg.GetPl
|
|||
return pg.GetPlaylistsResponse{}, fmt.Errorf("%s", errMsg)
|
||||
}
|
||||
|
||||
// Get the owner user ID from config (defaults to "user-1")
|
||||
ownerID := "user-1"
|
||||
if id, ok := pdk.GetConfig("owner_id"); ok && id != "" {
|
||||
ownerID = id
|
||||
// Get the owner username from config (defaults to "admin")
|
||||
ownerUsername := "admin"
|
||||
if u, ok := pdk.GetConfig("owner_username"); ok && u != "" {
|
||||
ownerUsername = u
|
||||
}
|
||||
|
||||
return pg.GetPlaylistsResponse{
|
||||
Playlists: []pg.PlaylistInfo{
|
||||
{ID: "daily-mix-1", OwnerUserID: ownerID},
|
||||
{ID: "daily-mix-2", OwnerUserID: ownerID},
|
||||
{ID: "daily-mix-1", OwnerUsername: ownerUsername},
|
||||
{ID: "daily-mix-2", OwnerUsername: ownerUsername},
|
||||
},
|
||||
RefreshInterval: 0, // No re-discovery in tests
|
||||
}, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue