fix(01-01): add mutex protection to Queue, Library, and Playlist SetContext methods
- Queue.SetContext acquires existing q.mu before writing q.ctx - Library struct gets new mu sync.Mutex; SetContext and SetRescanHooks acquire it - Playlist Service struct gets new mu sync.Mutex; SetContext and SetFavoritesConfig acquire it - Library and Playlist release lock before calling post-init methods (registerEventHandlers, migrateExistingPlaylists)
This commit is contained in:
@@ -132,6 +132,9 @@ func NewQueue(logger *slog.Logger, db *database.DB) *Queue {
|
||||
|
||||
// SetContext sets the Wails runtime context for event emission.
|
||||
func (q *Queue) SetContext(ctx context.Context) {
|
||||
q.mu.Lock()
|
||||
defer q.mu.Unlock()
|
||||
|
||||
q.ctx = ctx
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user