mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
refactor: simplify schedule cloning in Close method and enhance plugin cleanup error handling
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
a3993b52b3
commit
8207b74dd4
@ -3,6 +3,7 @@ package plugins
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -146,10 +147,7 @@ func (s *schedulerServiceImpl) CancelSchedule(ctx context.Context, scheduleID st
|
||||
// This is called when the plugin is unloaded.
|
||||
func (s *schedulerServiceImpl) Close() error {
|
||||
s.mu.Lock()
|
||||
schedules := make(map[string]*scheduleEntry, len(s.schedules))
|
||||
for k, v := range s.schedules {
|
||||
schedules[k] = v
|
||||
}
|
||||
schedules := maps.Clone(s.schedules)
|
||||
s.schedules = make(map[string]*scheduleEntry)
|
||||
s.mu.Unlock()
|
||||
|
||||
|
||||
@ -195,6 +195,10 @@ func (m *Manager) Stop() error {
|
||||
|
||||
// Close all plugins
|
||||
for name, plugin := range m.plugins {
|
||||
err := plugin.Close()
|
||||
if err != nil {
|
||||
log.Error("Error during plugin cleanup", "plugin", name, err)
|
||||
}
|
||||
if plugin.compiled != nil {
|
||||
if err := plugin.compiled.Close(context.Background()); err != nil {
|
||||
log.Error("Error closing plugin", "plugin", name, err)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user