From 9434c2f29b850860e181624a441fe000c3cc3412 Mon Sep 17 00:00:00 2001 From: Darren Yu Date: Sat, 13 Sep 2025 16:18:18 +0800 Subject: [PATCH] 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 --- application/migrator/policy.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/application/migrator/policy.go b/application/migrator/policy.go index 83c6c5e0..8ae263f9 100644 --- a/application/migrator/policy.go +++ b/application/migrator/policy.go @@ -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) }