🎨 插入资源文件时文件名长度最大限制 189 字节 https://github.com/siyuan-note/siyuan/issues/7099

This commit is contained in:
Liang Ding 2023-01-17 21:34:12 +08:00
parent 5734548f78
commit ce2fadac6a
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 5 additions and 3 deletions

View file

@ -54,11 +54,11 @@ func AssetName(name string) string {
_, id := LastID(name)
ext := path.Ext(name)
name = name[0 : len(name)-len(ext)]
if !IsIDPattern(id) {
if !ast.IsNodeIDPattern(id) {
id = ast.NewNodeID()
name = name + "-" + id + ext
} else {
if !IsIDPattern(name) {
if !ast.IsNodeIDPattern(name) {
name = name[:len(name)-len(id)-1] + "-" + id + ext
} else {
name = name + ext
@ -141,6 +141,8 @@ func FilterUploadFileName(name string) string {
ret = strings.ReplaceAll(ret, "#", "")
ret = strings.ReplaceAll(ret, "%", "")
ret = strings.ReplaceAll(ret, "$", "")
// 插入资源文件时文件名长度最大限制 189 字节 https://github.com/siyuan-note/siyuan/issues/7099
ret = gulu.Str.SubStr(ret, 63)
return ret
}