fix(plugins): clear plugin errors on startup to allow retrying

Plugins that entered an error state (e.g., incompatible with the
Navidrome version) would remain in that state across restarts, blocking
the user from retrying. This adds a ClearErrors method to
PluginRepository that resets the last_error field on all plugins, and
calls it during plugin manager startup before syncing and loading.

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2026-03-02 08:56:56 -05:00
parent d004f99f8f
commit 27a83547f7
5 changed files with 53 additions and 0 deletions

View file

@ -29,6 +29,20 @@ func (m *MockPluginRepo) SetError(err bool) {
m.Err = err
}
func (m *MockPluginRepo) ClearErrors() error {
if m.Err {
return errors.New("unexpected error")
}
for i := range m.All {
m.All[i].LastError = ""
}
for k, p := range m.Data {
p.LastError = ""
m.Data[k] = p
}
return nil
}
func (m *MockPluginRepo) SetData(plugins model.Plugins) {
m.Data = make(map[string]*model.Plugin, len(plugins))
m.All = plugins