Skip to content
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

Storage paths must be unique #26380

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
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
7 changes: 7 additions & 0 deletions modules/setting/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ func getDefaultStorageSection(rootCfg ConfigProvider) ConfigSection {
return storageSec
}

var storagePaths = make(map[string]string)

// getStorage will find target section and extra special section first and then read override
// items from extra section
func getStorage(rootCfg ConfigProvider, name, typ string, sec ConfigSection) (*Storage, error) {
Expand Down Expand Up @@ -206,6 +208,11 @@ func getStorage(rootCfg ConfigProvider, name, typ string, sec ConfigSection) (*S
}
}

if storageTarget, ok := storagePaths[storage.Path]; ok && storageTarget != name {
return nil, fmt.Errorf("storage path %q is being used by %q and %q and all storage paths must be unique to prevent data loss. Please set [storage.%s].PATH and [storage.%s].PATH to unique paths. For more information, see https://github.com/go-gitea/gitea/pull/26380", storage.Path, storageTarget, name, storageTarget, name)
}
storagePaths[storage.Path] = name

case string(MinioStorageType):
if err := targetSec.MapTo(&storage.MinioConfig); err != nil {
return nil, fmt.Errorf("map minio config failed: %v", err)
Expand Down