Skip to content

Commit

Permalink
🔖 Release v2.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 8, 2023
1 parent 5ede004 commit 147d083
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kernel/util/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,19 @@ func TruncateLenFileName(name string) (ret string) {
// 插入资源文件时文件名长度最大限制 189 字节 https://github.com/siyuan-note/siyuan/issues/7099
ext := filepath.Ext(name)
var byteCount int
truncated := false
buf := bytes.Buffer{}
for _, r := range name {
byteCount += utf8.RuneLen(r)
if 189-len(ext) < byteCount {
truncated = true
break
}
buf.WriteRune(r)
}
buf.WriteString(ext)
if truncated {
buf.WriteString(ext)
}
ret = buf.String()
return
}
Expand Down

0 comments on commit 147d083

Please sign in to comment.