mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Improve asset renaming https://github.com/siyuan-note/siyuan/issues/11889
This commit is contained in:
parent
644257998c
commit
427293f3e6
2 changed files with 6 additions and 4 deletions
|
|
@ -159,13 +159,16 @@ func renameAsset(c *gin.Context) {
|
||||||
|
|
||||||
oldPath := arg["oldPath"].(string)
|
oldPath := arg["oldPath"].(string)
|
||||||
newName := arg["newName"].(string)
|
newName := arg["newName"].(string)
|
||||||
err := model.RenameAsset(oldPath, newName)
|
newPath, err := model.RenameAsset(oldPath, newName)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
ret.Data = map[string]interface{}{"closeTimeout": 5000}
|
ret.Data = map[string]interface{}{"closeTimeout": 5000}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ret.Data = map[string]interface{}{
|
||||||
|
"newPath": newPath,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDocImageAssets(c *gin.Context) {
|
func getDocImageAssets(c *gin.Context) {
|
||||||
|
|
|
||||||
|
|
@ -762,7 +762,7 @@ func RemoveUnusedAsset(p string) (ret string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func RenameAsset(oldPath, newName string) (err error) {
|
func RenameAsset(oldPath, newName string) (newPath string, err error) {
|
||||||
util.PushEndlessProgress(Conf.Language(110))
|
util.PushEndlessProgress(Conf.Language(110))
|
||||||
defer util.PushClearProgress()
|
defer util.PushClearProgress()
|
||||||
|
|
||||||
|
|
@ -781,7 +781,7 @@ func RenameAsset(oldPath, newName string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
newName = util.AssetName(newName + filepath.Ext(oldPath))
|
newName = util.AssetName(newName + filepath.Ext(oldPath))
|
||||||
newPath := "assets/" + newName
|
newPath = "assets/" + newName
|
||||||
if err = filelock.Copy(filepath.Join(util.DataDir, oldPath), filepath.Join(util.DataDir, newPath)); nil != err {
|
if err = filelock.Copy(filepath.Join(util.DataDir, oldPath), filepath.Join(util.DataDir, newPath)); nil != err {
|
||||||
logging.LogErrorf("copy asset [%s] failed: %s", oldPath, err)
|
logging.LogErrorf("copy asset [%s] failed: %s", oldPath, err)
|
||||||
return
|
return
|
||||||
|
|
@ -842,7 +842,6 @@ func RenameAsset(oldPath, newName string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
IncSync()
|
IncSync()
|
||||||
util.ReloadUI()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue