Add plugin tasks (#651)

This commit is contained in:
WithoutPants
2020-08-08 12:05:35 +10:00
committed by GitHub
parent 0874852fa8
commit 0ffefa6e16
47 changed files with 2855 additions and 17 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/stashapp/stash/pkg/logger"
"github.com/stashapp/stash/pkg/manager/config"
"github.com/stashapp/stash/pkg/manager/paths"
"github.com/stashapp/stash/pkg/plugin"
"github.com/stashapp/stash/pkg/scraper"
"github.com/stashapp/stash/pkg/utils"
)
@@ -22,6 +23,7 @@ type singleton struct {
FFMPEGPath string
FFProbePath string
PluginCache *plugin.Cache
ScraperCache *scraper.Cache
}
@@ -51,6 +53,7 @@ func Initialize() *singleton {
Paths: paths.NewPaths(),
JSON: &jsonUtils{},
PluginCache: initPluginCache(),
ScraperCache: initScraperCache(),
}
@@ -88,8 +91,9 @@ func initConfig() {
// Set generated to the metadata path for backwards compat
viper.SetDefault(config.Generated, viper.GetString(config.Metadata))
// Set default scrapers path
// Set default scrapers and plugins paths
viper.SetDefault(config.ScrapersPath, config.GetDefaultScrapersPath())
viper.SetDefault(config.PluginsPath, config.GetDefaultPluginsPath())
// Disabling config watching due to race condition issue
// See: https://github.com/spf13/viper/issues/174
@@ -153,6 +157,16 @@ func initLog() {
logger.Init(config.GetLogFile(), config.GetLogOut(), config.GetLogLevel())
}
func initPluginCache() *plugin.Cache {
ret, err := plugin.NewCache(config.GetPluginsPath())
if err != nil {
logger.Errorf("Error reading plugin configs: %s", err.Error())
}
return ret
}
// initScraperCache initializes a new scraper cache and returns it.
func initScraperCache() *scraper.Cache {
scraperConfig := scraper.GlobalConfig{