From 5c3662b9021a090162629987b0ecf0b34f7f14e7 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 19 Jul 2023 04:24:07 +0800 Subject: [PATCH] Avoid creating directories when loading config (#25944) (#25957) Backport #25944 The "creating dir/file during load config" is a longstanding and complex problem. This PR only does a quick patch, it still needs more refactorings in the future. Fix #25938 --- modules/setting/packages.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/setting/packages.go b/modules/setting/packages.go index dc8d98d29f..b225615a24 100644 --- a/modules/setting/packages.go +++ b/modules/setting/packages.go @@ -74,8 +74,10 @@ func loadPackagesFrom(rootCfg ConfigProvider) (err error) { Packages.ChunkedUploadPath = filepath.ToSlash(filepath.Join(AppDataPath, Packages.ChunkedUploadPath)) } - if err := os.MkdirAll(Packages.ChunkedUploadPath, os.ModePerm); err != nil { - return fmt.Errorf("unable to create chunked upload directory: %s (%v)", Packages.ChunkedUploadPath, err) + if HasInstallLock(rootCfg) { + if err := os.MkdirAll(Packages.ChunkedUploadPath, os.ModePerm); err != nil { + return fmt.Errorf("unable to create chunked upload directory: %s (%v)", Packages.ChunkedUploadPath, err) + } } Packages.LimitTotalOwnerSize = mustBytes(sec, "LIMIT_TOTAL_OWNER_SIZE")