Skip to content

Commit 5c3662b

Browse files
authored
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
1 parent ab54310 commit 5c3662b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

modules/setting/packages.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ func loadPackagesFrom(rootCfg ConfigProvider) (err error) {
7474
Packages.ChunkedUploadPath = filepath.ToSlash(filepath.Join(AppDataPath, Packages.ChunkedUploadPath))
7575
}
7676

77-
if err := os.MkdirAll(Packages.ChunkedUploadPath, os.ModePerm); err != nil {
78-
return fmt.Errorf("unable to create chunked upload directory: %s (%v)", Packages.ChunkedUploadPath, err)
77+
if HasInstallLock(rootCfg) {
78+
if err := os.MkdirAll(Packages.ChunkedUploadPath, os.ModePerm); err != nil {
79+
return fmt.Errorf("unable to create chunked upload directory: %s (%v)", Packages.ChunkedUploadPath, err)
80+
}
7981
}
8082

8183
Packages.LimitTotalOwnerSize = mustBytes(sec, "LIMIT_TOTAL_OWNER_SIZE")

0 commit comments

Comments
 (0)