🐛 复制资源文件后导出再导入后丢失 Fix https://github.com/siyuan-note/siyuan/issues/5320

This commit is contained in:
Liang Ding 2022-06-30 11:29:05 +08:00
parent ea4f722edb
commit a0a3d2f28e
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 34 additions and 25 deletions

View file

@ -159,19 +159,7 @@ func Upload(c *gin.Context) {
// 已经存在同样数据的资源文件的话不重复保存
succMap[baseName] = existAsset.Path
} else {
_, id := util.LastID(fName)
ext := path.Ext(fName)
fName = fName[0 : len(fName)-len(ext)]
if !util.IsIDPattern(id) {
id = ast.NewNodeID()
fName = fName + "-" + id + ext
} else {
if !util.IsIDPattern(fName) {
fName = fName[:len(fName)-len(id)-1] + "-" + id + ext
} else {
fName = fName + ext
}
}
fName = util.AssetName(fName)
writePath := filepath.Join(assetsDirPath, fName)
if _, err = f.Seek(0, io.SeekStart); nil != err {
errFiles = append(errFiles, fName)