Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: The image file name is too long and truncated abnormally Fix https://github.com/siyuan-note/siyuan/issues/9129

Daniel6993a286bc84
diff --git a/kernel/util/file.go b/kernel/util/file.go
index 755b0a930d..1fc17237cc 100644
--- a/kernel/util/file.go
+++ b/kernel/util/file.go
@@ -134,15 +134,17 @@ func FilterUploadFileName(name string) string {
func TruncateLenFileName(name string) (ret string) {
// 插入资源文件时文件名长度最大限制 189 字节 https://github.com/siyuan-note/siyuan/issues/7099
+ ext := filepath.Ext(name)
var byteCount int
buf := bytes.Buffer{}
for _, r := range name {
byteCount += utf8.RuneLen(r)
- if 189 < byteCount {
+ if 189-len(ext) < byteCount {
break
}
buf.WriteRune(r)
}
+ buf.WriteString(ext)
ret = buf.String()
return
}