navidrome/model/scrobble_buffer.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
549 B
Go
Raw Normal View History

2021-06-24 00:01:05 -04:00
package model
import "time"
type ScrobbleEntry struct {
ID string
2021-06-24 00:01:05 -04:00
Service string
UserID string
2021-06-24 00:01:05 -04:00
PlayTime time.Time
EnqueueTime time.Time
MediaFileID string
MediaFile
2021-06-24 00:01:05 -04:00
}
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)
fix(plugins): discard buffered scrobbles when a plugin is removed (#5737) * 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.
2026-07-08 12:37:17 -04:00
Discard(service string) error
2021-06-24 00:01:05 -04:00
}