Skip to content

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

:bug: Dragging a file from the assets folder into the editor causes the kernel to exit https://github.com/siyuan-note/siyuan/issues/15355

Daniel10a760b97ab6
diff --git a/kernel/model/upload.go b/kernel/model/upload.go
index 04fcd83c2f..d75836aec5 100644
--- a/kernel/model/upload.go
+++ b/kernel/model/upload.go
@@ -33,7 +33,7 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
-func InsertLocalAssets(id string, assetPaths []string, isUpload bool) (succMap map[string]interface{}, err error) {
+func InsertLocalAssets(id string, assetAbsPaths []string, isUpload bool) (succMap map[string]interface{}, err error) {
succMap = map[string]interface{}{}
bt := treenode.GetBlockTree(id)
@@ -50,28 +50,35 @@ func InsertLocalAssets(id string, assetPaths []string, isUpload bool) (succMap m
}
}
- for _, p := range assetPaths {
- baseName := filepath.Base(p)
+ for _, assetAbsPath := range assetAbsPaths {
+ baseName := filepath.Base(assetAbsPath)
fName := baseName
fName = util.FilterUploadFileName(fName)
ext := filepath.Ext(fName)
fName = strings.TrimSuffix(fName, ext)
ext = strings.ToLower(ext)
fName += ext
- if gulu.File.IsDir(p) || !isUpload {
- if !strings.HasPrefix(p, "\\\\") {
- p = "file://" + p
+ if gulu.File.IsDir(assetAbsPath) || !isUpload {
+ if !strings.HasPrefix(assetAbsPath, "\\\\") {
+ assetAbsPath = "file://" + assetAbsPath
}
- succMap[baseName] = p
+ succMap[baseName] = assetAbsPath
continue
}
- fi, statErr := os.Stat(p)
+ if util.IsSubPath(assetsDirPath, assetAbsPath) {
+ // 已经位于 assets 目录下的资源文件不处理
+ // Dragging a file from the assets folder into the editor causes the kernel to exit https://github.com/siyuan-note/siyuan/issues/15355
+ succMap[baseName] = "assets/" + fName
+ continue
+ }
+
+ fi, statErr := os.Stat(assetAbsPath)
if nil != statErr {
err = statErr
return
}
- f, openErr := os.Open(p)
+ f, openErr := os.Open(assetAbsPath)
if nil != openErr {
err = openErr
return