🎨 Improve upload asset to cloud error message
This commit is contained in:
parent
fe9ffed025
commit
1ce56dee21
2 changed files with 6 additions and 6 deletions
|
@ -548,11 +548,10 @@ func UploadAssets2Cloud(rootID string) (count int, err error) {
|
|||
embedAssets := assetsLinkDestsInQueryEmbedNodes(tree)
|
||||
assets = append(assets, embedAssets...)
|
||||
assets = gulu.Str.RemoveDuplicatedElem(assets)
|
||||
err = uploadAssets2Cloud(assets, bizTypeUploadAssets)
|
||||
count, err = uploadAssets2Cloud(assets, bizTypeUploadAssets)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
count = len(assets)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -562,7 +561,7 @@ const (
|
|||
)
|
||||
|
||||
// uploadAssets2Cloud 将资源文件上传到云端图床。
|
||||
func uploadAssets2Cloud(assetPaths []string, bizType string) (err error) {
|
||||
func uploadAssets2Cloud(assetPaths []string, bizType string) (count int, err error) {
|
||||
var uploadAbsAssets []string
|
||||
for _, assetPath := range assetPaths {
|
||||
var absPath string
|
||||
|
@ -612,7 +611,7 @@ func uploadAssets2Cloud(assetPaths []string, bizType string) (err error) {
|
|||
fi, statErr := os.Stat(absAsset)
|
||||
if nil != statErr {
|
||||
logging.LogErrorf("stat file [%s] failed: %s", absAsset, statErr)
|
||||
return statErr
|
||||
return count, statErr
|
||||
}
|
||||
|
||||
if limitSize < uint64(fi.Size()) {
|
||||
|
@ -637,7 +636,7 @@ func uploadAssets2Cloud(assetPaths []string, bizType string) (err error) {
|
|||
Post(util.GetCloudServer() + "/apis/siyuan/upload?ver=" + util.Ver)
|
||||
if nil != reqErr {
|
||||
logging.LogErrorf("upload assets failed: %s", reqErr)
|
||||
return ErrFailedToConnectCloudServer
|
||||
return count, ErrFailedToConnectCloudServer
|
||||
}
|
||||
|
||||
if 401 == resp.StatusCode {
|
||||
|
@ -655,6 +654,7 @@ func uploadAssets2Cloud(assetPaths []string, bizType string) (err error) {
|
|||
relAsset := absAsset[strings.Index(absAsset, "assets/"):]
|
||||
completedUploadAssets = append(completedUploadAssets, relAsset)
|
||||
logging.LogInfof("uploaded asset [%s]", relAsset)
|
||||
count++
|
||||
}
|
||||
util.PushClearMsg(msgId)
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ func Export2Liandi(id string) (err error) {
|
|||
embedAssets := assetsLinkDestsInQueryEmbedNodes(tree)
|
||||
assets = append(assets, embedAssets...)
|
||||
assets = gulu.Str.RemoveDuplicatedElem(assets)
|
||||
err = uploadAssets2Cloud(assets, bizTypeExport2Liandi)
|
||||
_, err = uploadAssets2Cloud(assets, bizTypeExport2Liandi)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue