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
This commit is contained in:
wxiaoguang 2023-07-19 04:24:07 +08:00 committed by GitHub
parent ab54310731
commit 5c3662b902
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,9 +74,11 @@ func loadPackagesFrom(rootCfg ConfigProvider) (err error) {
Packages.ChunkedUploadPath = filepath.ToSlash(filepath.Join(AppDataPath, Packages.ChunkedUploadPath))
}
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")
Packages.LimitSizeAlpine = mustBytes(sec, "LIMIT_SIZE_ALPINE")