fix(upgrade v3): validation on unique magic var in either blob name or path (#2890)

* fix(upgrade v3): validation on unique magic var in either blob name or path

* Update policy.go
pull/2897/head
Darren Yu 2025-09-13 16:18:18 +08:00 committed by GitHub
parent 7d97237593
commit 9434c2f29b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -103,10 +103,6 @@ func (m *Migrator) migratePolicy() (map[int]bool, error) {
settings.ProxyServer = policy.OptionsSerialized.OdProxy
}
if policy.DirNameRule == "" {
policy.DirNameRule = "uploads/{uid}/{path}"
}
if policy.Type == types.PolicyTypeCos {
settings.ChunkSize = 1024 * 1024 * 25
}
@ -122,8 +118,16 @@ func (m *Migrator) migratePolicy() (map[int]bool, error) {
hasRandomElement = true
break
}
if strings.Contains(policy.DirNameRule, c) {
hasRandomElement = true
break
}
}
if !hasRandomElement {
if policy.DirNameRule == "" {
policy.DirNameRule = "uploads/{uid}/{path}"
}
policy.FileNameRule = "{uid}_{randomkey8}_{originname}"
m.l.Warning("Storage policy %q has no random element in file name rule, using default file name rule.", policy.Name)
}