소스 검색

:art: Add kernel API `/api/file/renameFile` https://github.com/siyuan-note/siyuan/issues/8328

Daniel 2 년 전
부모
커밋
0ef094bc44
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      kernel/api/file.go

+ 3 - 1
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)