From 23657408de0494683c0a968ea242c44e8820f9df Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Mon, 18 Nov 2019 08:42:24 +1100 Subject: [PATCH] Refresh config when paths change (#217) --- pkg/api/resolver_mutation_configure.go | 3 +++ pkg/api/server.go | 3 +++ pkg/manager/manager.go | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/api/resolver_mutation_configure.go b/pkg/api/resolver_mutation_configure.go index 4b81d2bfb..e29a8a9dc 100644 --- a/pkg/api/resolver_mutation_configure.go +++ b/pkg/api/resolver_mutation_configure.go @@ -6,6 +6,7 @@ import ( "path/filepath" "github.com/stashapp/stash/pkg/logger" + "github.com/stashapp/stash/pkg/manager" "github.com/stashapp/stash/pkg/manager/config" "github.com/stashapp/stash/pkg/models" "github.com/stashapp/stash/pkg/utils" @@ -75,6 +76,8 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input models.Co return makeConfigGeneralResult(), err } + manager.GetInstance().RefreshConfig() + return makeConfigGeneralResult(), nil } diff --git a/pkg/api/server.go b/pkg/api/server.go index 5cdbea268..49abbe158 100644 --- a/pkg/api/server.go +++ b/pkg/api/server.go @@ -21,6 +21,7 @@ import ( "github.com/gorilla/websocket" "github.com/rs/cors" "github.com/stashapp/stash/pkg/logger" + "github.com/stashapp/stash/pkg/manager" "github.com/stashapp/stash/pkg/manager/config" "github.com/stashapp/stash/pkg/manager/paths" "github.com/stashapp/stash/pkg/models" @@ -183,6 +184,8 @@ func Start() { return } + manager.GetInstance().RefreshConfig() + http.Redirect(w, r, "/", 301) }) diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go index c63a048e3..437f3d8da 100644 --- a/pkg/manager/manager.go +++ b/pkg/manager/manager.go @@ -43,7 +43,7 @@ func Initialize() *singleton { JSON: &jsonUtils{}, } - instance.refreshConfig() + instance.RefreshConfig() initFFMPEG() }) @@ -131,7 +131,7 @@ func initLog() { logger.Init(config.GetLogFile(), config.GetLogOut(), config.GetLogLevel()) } -func (s *singleton) refreshConfig() { +func (s *singleton) RefreshConfig() { s.Paths = paths.NewPaths() if config.IsValid() { _ = utils.EnsureDir(s.Paths.Generated.Screenshots)