Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/16807

Daniel2c907ab2d75b
diff --git a/kernel/model/assets.go b/kernel/model/assets.go
index 63b306366c..984b70d98a 100644
--- a/kernel/model/assets.go
+++ b/kernel/model/assets.go
@@ -203,6 +203,7 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
forbiddenCount := 0
destNodes := getRemoteAssetsLinkDestsInTree(tree, onlyImg)
+ assetsMap := map[string]string{}
for _, destNode := range destNodes {
dests := getRemoteAssetsLinkDests(destNode, onlyImg)
if 1 > len(dests) {
@@ -228,7 +229,13 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
continue
}
- name := filepath.Base(u)
+ name := assetsMap[u]
+ if "" != name {
+ setAssetsLinkDest(destNode, dest, "assets/"+name)
+ continue
+ }
+
+ name = filepath.Base(u)
name = util.FilterUploadFileName(name)
name = "network-asset-" + name
name = util.AssetName(name, ast.NewNodeID())
@@ -239,6 +246,7 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
}
setAssetsLinkDest(destNode, dest, "assets/"+name)
+ assetsMap[u] = name
files++
size += gulu.File.GetFileSize(writePath)
continue
@@ -266,6 +274,12 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
//}
}
+ name := assetsMap[u]
+ if "" != name {
+ setAssetsLinkDest(destNode, dest, "assets/"+name)
+ continue
+ }
+
displayU := u
if 64 < len(displayU) {
displayU = displayU[:64] + "..."
@@ -303,7 +317,6 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
logging.LogErrorf("download network asset [%s] failed: %s", u, repErr)
continue
}
- var name string
if strings.Contains(u, "?") {
name = u[:strings.Index(u, "?")]
name = path.Base(name)
@@ -343,6 +356,7 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
}
setAssetsLinkDest(destNode, dest, "assets/"+name)
+ assetsMap[u] = name
files++
size += int64(len(data))
continue