mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🔖 Release v2.10.4
This commit is contained in:
parent
5ede004dfb
commit
147d083770
1 changed files with 5 additions and 1 deletions
|
|
@ -136,15 +136,19 @@ func TruncateLenFileName(name string) (ret string) {
|
||||||
// 插入资源文件时文件名长度最大限制 189 字节 https://github.com/siyuan-note/siyuan/issues/7099
|
// 插入资源文件时文件名长度最大限制 189 字节 https://github.com/siyuan-note/siyuan/issues/7099
|
||||||
ext := filepath.Ext(name)
|
ext := filepath.Ext(name)
|
||||||
var byteCount int
|
var byteCount int
|
||||||
|
truncated := false
|
||||||
buf := bytes.Buffer{}
|
buf := bytes.Buffer{}
|
||||||
for _, r := range name {
|
for _, r := range name {
|
||||||
byteCount += utf8.RuneLen(r)
|
byteCount += utf8.RuneLen(r)
|
||||||
if 189-len(ext) < byteCount {
|
if 189-len(ext) < byteCount {
|
||||||
|
truncated = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
buf.WriteRune(r)
|
buf.WriteRune(r)
|
||||||
}
|
}
|
||||||
buf.WriteString(ext)
|
if truncated {
|
||||||
|
buf.WriteString(ext)
|
||||||
|
}
|
||||||
ret = buf.String()
|
ret = buf.String()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue