mirror of
https://github.com/navidrome/navidrome.git
synced 2026-05-03 06:51:16 +00:00
refactor(plugins): streamline plugin loading and synchronization logic
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
04aa10f988
commit
f9af67d45e
@ -373,8 +373,7 @@ func (m *Manager) loadPluginWithConfig(p *model.Plugin) error {
|
|||||||
return fmt.Errorf("manifest validation: %w", err)
|
return fmt.Errorf("manifest validation: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.mu.Lock()
|
loadedPlugin := &plugin{
|
||||||
m.plugins[p.ID] = &plugin{
|
|
||||||
name: p.ID,
|
name: p.ID,
|
||||||
path: p.Path,
|
path: p.Path,
|
||||||
manifest: pkg.Manifest,
|
manifest: pkg.Manifest,
|
||||||
@ -386,13 +385,14 @@ func (m *Manager) loadPluginWithConfig(p *model.Plugin) error {
|
|||||||
allUsers: p.AllUsers,
|
allUsers: p.AllUsers,
|
||||||
libraries: newLibraryAccess(allowedLibraries, p.AllLibraries),
|
libraries: newLibraryAccess(allowedLibraries, p.AllLibraries),
|
||||||
}
|
}
|
||||||
|
m.mu.Lock()
|
||||||
|
m.plugins[p.ID] = loadedPlugin
|
||||||
m.mu.Unlock()
|
m.mu.Unlock()
|
||||||
|
|
||||||
// Call plugin init function
|
// Call plugin init function
|
||||||
callPluginInit(ctx, m.plugins[p.ID])
|
callPluginInit(ctx, m.plugins[p.ID])
|
||||||
|
|
||||||
// Start PlaylistProvider syncer if capability is detected
|
// Start PlaylistProvider syncer if capability is detected
|
||||||
loadedPlugin := m.plugins[p.ID]
|
|
||||||
if hasCapability(loadedPlugin.capabilities, CapabilityPlaylistProvider) {
|
if hasCapability(loadedPlugin.capabilities, CapabilityPlaylistProvider) {
|
||||||
syncer := newPlaylistSyncer(m.ctx, p.ID, loadedPlugin, m.ds, m.matcher)
|
syncer := newPlaylistSyncer(m.ctx, p.ID, loadedPlugin, m.ds, m.matcher)
|
||||||
loadedPlugin.closers = append(loadedPlugin.closers, syncer)
|
loadedPlugin.closers = append(loadedPlugin.closers, syncer)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user