Skip to content

Fix the wrong derive path #26271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Aug 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
code improvement
  • Loading branch information
lunny committed Aug 2, 2023
commit 903dcb940fff7d8193f8cb870f5dd6702accfc7c
20 changes: 8 additions & 12 deletions modules/setting/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ func getStorage(rootCfg ConfigProvider, name, typ string, sec ConfigSection) (*S
return nil, fmt.Errorf("invalid storage type %q", targetType)
}

// extra config section will be read SERVE_DIRECT, PATH, MINIO_BASE_PATH, MINIO_BUCKET to override the targetsec when possible
extraConfigSec := sec
if extraConfigSec == nil {
extraConfigSec = storageNameSec
}

var storage Storage
storage.Type = StorageType(targetType)

Expand All @@ -163,11 +169,6 @@ func getStorage(rootCfg ConfigProvider, name, typ string, sec ConfigSection) (*S
targetPath = AppDataPath
}

extraConfigSec := sec
if extraConfigSec == nil {
extraConfigSec = storageNameSec
}

if extraConfigSec == nil {
storage.Path = filepath.Join(targetPath, name)
} else {
Expand All @@ -179,21 +180,16 @@ func getStorage(rootCfg ConfigProvider, name, typ string, sec ConfigSection) (*S
}

case string(MinioStorageType):
storage.MinioConfig.BasePath = name + "/"

if err := targetSec.MapTo(&storage.MinioConfig); err != nil {
return nil, fmt.Errorf("map minio config failed: %v", err)
}
// extra config section will be read SERVE_DIRECT, PATH, MINIO_BASE_PATH to override the targetsec
extraConfigSec := sec
if extraConfigSec == nil {
extraConfigSec = storageNameSec
}

if extraConfigSec != nil {
storage.MinioConfig.ServeDirect = ConfigSectionKeyBool(extraConfigSec, "SERVE_DIRECT", storage.MinioConfig.ServeDirect)
storage.MinioConfig.BasePath = ConfigSectionKeyString(extraConfigSec, "MINIO_BASE_PATH", storage.MinioConfig.BasePath)
storage.MinioConfig.Bucket = ConfigSectionKeyString(extraConfigSec, "MINIO_BUCKET", storage.MinioConfig.Bucket)
} else {
storage.MinioConfig.BasePath = name + "/"
}
}

Expand Down