From 938f450097e53714bd497a027a7464e008640e7d Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 29 Jun 2023 09:45:52 +0800 Subject: [PATCH] :art: Renaming a directory using the kernel API `/api/file/renameFile` indicates that the file is in use https://github.com/siyuan-note/siyuan/issues/8635 --- kernel/api/file.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/api/file.go b/kernel/api/file.go index c40767d2a..675c04906 100644 --- a/kernel/api/file.go +++ b/kernel/api/file.go @@ -196,6 +196,7 @@ func renameFile(c *gin.Context) { _, err := os.Stat(filePath) if os.IsNotExist(err) { ret.Code = 404 + ret.Msg = err.Error() return } if nil != err { @@ -207,6 +208,11 @@ func renameFile(c *gin.Context) { newPath := arg["newPath"].(string) newPath = filepath.Join(util.WorkspaceDir, newPath) + if gulu.File.IsExist(newPath) { + ret.Code = 409 + ret.Msg = "the [newPath] file or directory already exists" + return + } if err = filelock.Rename(filePath, newPath); nil != err { logging.LogErrorf("rename file [%s] to [%s] failed: %s", filePath, newPath, err)