Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

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

Daniel0ef094bc44ef
diff --git a/kernel/api/file.go b/kernel/api/file.go
index e608d94ba9..ea32cb6972 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)