Do not allow different storage configurations to point to the same directory (#30169)

Replace #29171
This commit is contained in:
wxiaoguang 2024-03-31 11:03:24 +08:00 committed by GitHub
parent 82ffd91607
commit 6d34ce25b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 75 additions and 47 deletions

View file

@ -230,11 +230,14 @@ func LoadSettingsForInstall() {
loadMailerFrom(CfgProvider)
}
var uniquePaths = make(map[string]string)
var configuredPaths = make(map[string]string)
func fatalDuplicatedPath(name, p string) {
if targetName, ok := uniquePaths[p]; ok && targetName != name {
log.Fatal("storage path %q is being used by %q and %q and all storage paths must be unique to prevent data loss.", p, targetName, name)
func checkOverlappedPath(name, path string) {
// TODO: some paths shouldn't overlap (storage.xxx.path), while some could (data path is the base path for storage path)
if targetName, ok := configuredPaths[path]; ok && targetName != name {
msg := fmt.Sprintf("Configured path %q is used by %q and %q at the same time. The paths must be unique to prevent data loss.", path, targetName, name)
log.Error("%s", msg)
DeprecatedWarnings = append(DeprecatedWarnings, msg)
}
uniquePaths[p] = name
configuredPaths[path] = name
}