mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Improve plugin hook cyclic detection (#4625)
* Move and rename HookTriggerEnum into separate package * Move visited plugin hook handler code * Allow up to ten plugin hook loops
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/plugin"
|
||||
"github.com/stashapp/stash/pkg/plugin/hook"
|
||||
)
|
||||
|
||||
func (s *Service) Create(ctx context.Context, input *models.Scene, fileIDs []models.FileID, coverImage []byte) (*models.Scene, error) {
|
||||
@@ -54,7 +54,7 @@ func (s *Service) Create(ctx context.Context, input *models.Scene, fileIDs []mod
|
||||
}
|
||||
}
|
||||
|
||||
s.PluginCache.RegisterPostHooks(ctx, ret.ID, plugin.SceneCreatePost, nil, nil)
|
||||
s.PluginCache.RegisterPostHooks(ctx, ret.ID, hook.SceneCreatePost, nil, nil)
|
||||
|
||||
// re-find the scene so that it correctly returns file-related fields
|
||||
return ret, nil
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/paths"
|
||||
"github.com/stashapp/stash/pkg/plugin"
|
||||
"github.com/stashapp/stash/pkg/plugin/hook"
|
||||
"github.com/stashapp/stash/pkg/txn"
|
||||
)
|
||||
|
||||
@@ -107,7 +108,7 @@ func (h *ScanHandler) Handle(ctx context.Context, f models.File, oldFile models.
|
||||
return fmt.Errorf("creating new scene: %w", err)
|
||||
}
|
||||
|
||||
h.PluginCache.RegisterPostHooks(ctx, newScene.ID, plugin.SceneCreatePost, nil, nil)
|
||||
h.PluginCache.RegisterPostHooks(ctx, newScene.ID, hook.SceneCreatePost, nil, nil)
|
||||
|
||||
existing = []*models.Scene{&newScene}
|
||||
}
|
||||
@@ -164,7 +165,7 @@ func (h *ScanHandler) associateExisting(ctx context.Context, existing []*models.
|
||||
}
|
||||
|
||||
if !found || updateExisting {
|
||||
h.PluginCache.RegisterPostHooks(ctx, s.ID, plugin.SceneUpdatePost, nil, nil)
|
||||
h.PluginCache.RegisterPostHooks(ctx, s.ID, hook.SceneUpdatePost, nil, nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user