Przeglądaj źródła

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

Daniel 2 lat temu
rodzic
commit
8c843f8775
1 zmienionych plików z 5 dodań i 3 usunięć
  1. 5 3
      kernel/api/file.go

+ 5 - 3
kernel/api/file.go

@@ -185,12 +185,13 @@ func renameFile(c *gin.Context) {
 	filePath = filepath.Join(util.WorkspaceDir, filePath)
 	_, err := os.Stat(filePath)
 	if os.IsNotExist(err) {
-		c.Status(404)
+		ret.Code = 404
 		return
 	}
 	if nil != err {
 		logging.LogErrorf("stat [%s] failed: %s", filePath, err)
-		c.Status(500)
+		ret.Code = 500
+		ret.Msg = err.Error()
 		return
 	}
 
@@ -199,7 +200,8 @@ func renameFile(c *gin.Context) {
 
 	if err = filelock.Rename(filePath, newPath); nil != err {
 		logging.LogErrorf("rename file [%s] to [%s] failed: %s", filePath, newPath, err)
-		c.Status(500)
+		ret.Code = 500
+		ret.Msg = err.Error()
 		return
 	}
 }