mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🐛 The image file name is too long and truncated abnormally Fix https://github.com/siyuan-note/siyuan/issues/9129
This commit is contained in:
parent
3480f78870
commit
6993a286bc
1 changed files with 3 additions and 1 deletions
|
|
@ -134,15 +134,17 @@ func FilterUploadFileName(name string) string {
|
||||||
|
|
||||||
func TruncateLenFileName(name string) (ret string) {
|
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)
|
||||||
var byteCount int
|
var byteCount int
|
||||||
buf := bytes.Buffer{}
|
buf := bytes.Buffer{}
|
||||||
for _, r := range name {
|
for _, r := range name {
|
||||||
byteCount += utf8.RuneLen(r)
|
byteCount += utf8.RuneLen(r)
|
||||||
if 189 < byteCount {
|
if 189-len(ext) < byteCount {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
buf.WriteRune(r)
|
buf.WriteRune(r)
|
||||||
}
|
}
|
||||||
|
buf.WriteString(ext)
|
||||||
ret = buf.String()
|
ret = buf.String()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue