mirror of
https://github.com/navidrome/navidrome.git
synced 2026-07-30 16:56:22 -04:00
* fix(plugins): discard buffered scrobbles when a plugin is removed Scrobbles are buffered in the DB per service, keyed by the plugin name. When a plugin was removed (deleted from the plugins folder and detected by the sync), its pending buffer entries were left behind forever: the drain goroutine is stopped on the next scrobbler refresh, so the rows were never retried nor discarded. Worse, if a plugin with the same name was installed later, the stale entries would be drained into it - potentially a completely unrelated plugin that just reuses the name. Add a Discard(service) method to ScrobbleBufferRepository and call it from removePluginFromDB, right after the plugin record is deleted. Disabling a plugin intentionally keeps its buffered scrobbles, consistent with the buffer's purpose of surviving temporary outages, and transient unload/reload cycles during config updates are unaffected since they never delete the plugin record. * fix(plugins): don't wipe builtin scrobbler queues on plugin removal Buffer entries are keyed by service name only, and removePluginFromDB runs for any removed plugin file, so removing a plugin named e.g. lastfm.ndp - regardless of its capability - would discard the builtin Last.fm retry queue. Skip the discard when the plugin name is owned by a registered builtin scrobbler, exposed via a new scrobbler.IsBuiltinScrobbler helper. Reported by Codex review on the PR. Also drop the testBroker usage from the new removePluginFromDB spec: it is defined in manager_test.go which is excluded on Windows, breaking the Windows test build. sendPluginRefreshEvent is nil-safe, so no broker is needed.
25 lines
549 B
Go
25 lines
549 B
Go
package model
|
|
|
|
import "time"
|
|
|
|
type ScrobbleEntry struct {
|
|
ID string
|
|
Service string
|
|
UserID string
|
|
PlayTime time.Time
|
|
EnqueueTime time.Time
|
|
MediaFileID string
|
|
MediaFile
|
|
}
|
|
|
|
type ScrobbleEntries []ScrobbleEntry
|
|
|
|
type ScrobbleBufferRepository interface {
|
|
UserIDs(service string) ([]string, error)
|
|
Enqueue(service, userId, mediaFileId string, playTime time.Time) error
|
|
Next(service string, userId string) (*ScrobbleEntry, error)
|
|
Dequeue(entry *ScrobbleEntry) error
|
|
Length() (int64, error)
|
|
Discard(service string) error
|
|
}
|