This commit is contained in:
Daniel 2025-01-26 10:28:36 +08:00
parent 5143121ac4
commit 8e90578a21
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
13 changed files with 40 additions and 14 deletions

View file

@ -98,6 +98,7 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
EnableInsecureSkipVerify().
SetProxy(httpclient.ProxyFromEnvironment)
forbiddenCount := 0
destNodes := getRemoteAssetsLinkDestsInTree(tree, onlyImg)
for _, destNode := range destNodes {
dests := getRemoteAssetsLinkDests(destNode, onlyImg)
@ -172,6 +173,10 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
request.SetHeader("Referer", originalURL) // 改进浏览器剪藏扩展转换本地图片成功率 https://github.com/siyuan-note/siyuan/issues/7464
}
resp, reqErr := request.Get(u)
if http.StatusForbidden == resp.StatusCode || http.StatusUnauthorized == resp.StatusCode {
forbiddenCount++
}
if strings.Contains(strings.ToLower(resp.GetContentType()), "text/html") {
// 忽略超链接网页 `Convert network assets to local` no longer process webpage https://github.com/siyuan-note/siyuan/issues/9965
continue
@ -242,14 +247,23 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
}
}
util.PushClearMsg(msgId)
if 0 < files {
util.PushUpdateMsg(msgId, Conf.Language(113), 7000)
msgId = util.PushMsg(Conf.Language(113), 7000)
if err = writeTreeUpsertQueue(tree); err != nil {
return
}
util.PushUpdateMsg(msgId, fmt.Sprintf(Conf.Language(120), files), 5000)
if 0 < forbiddenCount {
util.PushErrMsg(fmt.Sprintf(Conf.Language(255), forbiddenCount), 5000)
}
} else {
util.PushUpdateMsg(msgId, Conf.Language(121), 3000)
if 0 < forbiddenCount {
util.PushErrMsg(fmt.Sprintf(Conf.Language(255), forbiddenCount), 5000)
} else {
util.PushMsg(Conf.Language(121), 3000)
}
}
return
}