mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 00:12:42 +08:00
🎨 Improve renaming assets https://github.com/siyuan-note/siyuan/issues/14467
This commit is contained in:
parent
06417acc1f
commit
f43699b2c4
@ -649,9 +649,16 @@ func RenameAsset(oldPath, newName string) (newPath string, err error) {
|
||||
}
|
||||
|
||||
newName = util.AssetName(newName + filepath.Ext(oldPath))
|
||||
newPath = "assets/" + newName
|
||||
if err = filelock.Copy(filepath.Join(util.DataDir, oldPath), filepath.Join(util.DataDir, newPath)); err != nil {
|
||||
logging.LogErrorf("copy asset [%s] failed: %s", oldPath, err)
|
||||
parentDir := path.Dir(oldPath)
|
||||
newPath = path.Join(parentDir, newName)
|
||||
oldAbsPath, getErr := GetAssetAbsPath(oldPath)
|
||||
if getErr != nil {
|
||||
logging.LogErrorf("get asset [%s] abs path failed: %s", oldPath, getErr)
|
||||
return
|
||||
}
|
||||
newAbsPath := filepath.Join(filepath.Dir(oldAbsPath), newName)
|
||||
if err = filelock.Copy(oldAbsPath, newAbsPath); err != nil {
|
||||
logging.LogErrorf("copy asset [%s] failed: %s", oldAbsPath, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user