From 0ef094bc44efa8526924a31f6f2c9570948d0115 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 23 May 2023 09:08:01 +0800 Subject: [PATCH] :art: Add kernel API `/api/file/renameFile` https://github.com/siyuan-note/siyuan/issues/8328 --- kernel/api/file.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/api/file.go b/kernel/api/file.go index e608d94ba..ea32cb697 100644 --- a/kernel/api/file.go +++ b/kernel/api/file.go @@ -182,7 +182,6 @@ func renameFile(c *gin.Context) { } filePath := arg["path"].(string) - newPath := arg["newPath"].(string) filePath = filepath.Join(util.WorkspaceDir, filePath) _, err := os.Stat(filePath) if os.IsNotExist(err) { @@ -195,6 +194,9 @@ func renameFile(c *gin.Context) { return } + newPath := arg["newPath"].(string) + newPath = filepath.Join(util.WorkspaceDir, newPath) + if err = filelock.Rename(filePath, newPath); nil != err { logging.LogErrorf("rename file [%s] to [%s] failed: %s", filePath, newPath, err) c.Status(500)