mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-17 06:05:29 +01:00
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
790493097c
commit
2c907ab2d7
1 changed files with 16 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue