-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(blob path): Random variables in blob save path be wrongly fixed #2741
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
Conversation
Fixed, as well as some problem in indent character. @HFO4 |
pkg/filemanager/fs/dbfs/dbfs.go
Outdated
} | ||
|
||
nameRule := policy.FileNameRule | ||
nameRule = util.Replace(baseTable, nameRule) | ||
nameRule = util.Replace(nameTable, nameRule) | ||
nameRule = filepath.ToSlash(nameRule) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this? If it's working now, we'd better not change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emm.. As now we ask the blob path to include at least one random item, but the check in frontend only in blob name
but not include the base path
.
Thus, in some storage policies which do not keep the name as download, some may set the base path
like upload/{uid}
but the blob name
to be {uuid}/{org. name}
. So i think maybe add a .ToSlash
here will be better (though not support 😄)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, maybe another solution to be turn the two setting item into a single one full_blob_path
, but this need update in database when upgrade version and i m not sure how to do that.
Or use another js function to check the validation of the base path
+blob name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change the frontend validation rule, as long as one of path/blob name contains random item, it will be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. i will remove this.
@@ -785,24 +780,50 @@ func generateSavePath(policy *ent.StoragePolicy, req *fs.UploadRequest, user *en | |||
"{second}": time.Now().Format("05"), | |||
} | |||
|
|||
dynamicReplace := func(regPattern string, rule string) string { | |||
re := regexp.MustCompile(regPattern) | |||
return re.ReplaceAllStringFunc(rule, func(match string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we try to use regex to match and replace all available variables (as long as it's wrapped by {
and }
)? Including those in fixedBaseTable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is fine. I'll update that later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. @HFO4
Thanks! |
No description provided.