{"record":{"id":"b8965ed1bbecac52","repo":"siyuan-note/siyuan","slug":"errors-new-msg-with-conf-language-5-template-mo","errorCode":null,"errorMessage":"errors.New(msg) with Conf.Language(5) template: move failure message shown to user","messagePattern":"errors\\.New\\(msg\\) with Conf\\.Language\\(5\\) template: move failure message shown to user","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/box.go","lineNumber":520,"sourceCode":"\tIncSync()\n\treturn nil\n}\n\nfunc (box *Box) Move(oldPath, newPath string) error {\n\tif _, err := box.validateBoxPath(oldPath); err != nil {\n\t\treturn err\n\t}\n\tif _, err := box.validateBoxPath(newPath); err != nil {\n\t\treturn err\n\t}\n\tboxLocalPath := filepath.Join(util.DataDir, box.ID)\n\tfromPath := filepath.Join(boxLocalPath, oldPath)\n\ttoPath := filepath.Join(boxLocalPath, newPath)\n\n\tif err := filelock.Rename(fromPath, toPath); err != nil {\n\t\tmsg := fmt.Sprintf(Conf.Language(5), box.Name, fromPath, err)\n\t\tlogging.LogErrorf(\"move [path=%s] in box [%s] failed: %s\", fromPath, box.Name, err)\n\t\treturn errors.New(msg)\n\t}\n\n\tif oldDir := path.Dir(oldPath); ast.IsNodeIDPattern(path.Base(oldDir)) {\n\t\tfromDir := filepath.Join(boxLocalPath, oldDir)\n\t\tif util.IsEmptyDir(fromDir) {\n\t\t\tfilelock.Remove(fromDir)\n\t\t}\n\t}\n\tIncSync()\n\treturn nil\n}\n\nfunc (box *Box) Remove(path string) error {\n\tif _, err := box.validateBoxPath(path); err != nil {\n\t\treturn err\n\t}\n\tboxLocalPath := filepath.Join(util.DataDir, box.ID)\n\tfilePath := filepath.Join(boxLocalPath, path)","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/box.go#L502-L538","documentation":"Box.Move renames a path inside a notebook via filelock.Rename (called from moveDoc). On failure it formats the localized template Conf.Language(5) with box name, source path and OS error, and returns errors.New(msg).","triggerScenarios":"Renaming/moving a document when the source is missing, the destination already exists, or the filesystem cannot perform the rename (cross-device link, permission denied, path traversal already excluded by validation).","commonSituations":"Two clients moving the same doc concurrently; destination name already taken (duplicate title); data dir on a network mount where rename semantics differ; doc deleted externally before the move.","solutions":["Read the OS error inside the message (e.g. 'no such file', 'file exists')","Pick a destination name/path that does not already exist","Retry after concurrent edits/syncs settle; ensure the source document still exists","Avoid moving across mount points; keep the whole workspace on one filesystem"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := os.Stat(fromPath); err != nil { return errors.New(\"source document missing\") }; if _, err := os.Stat(toPath); err == nil { return errors.New(\"destination already exists\") }","typeGuard":null,"tryCatchPattern":"if err := box.Move(oldPath, newPath); err != nil { showErrorToUser(err.Error()) }","preventionTips":["Check destination uniqueness before moving","Retry after concurrent moves from other clients settle","Keep the workspace on a single filesystem"],"tags":["filesystem","rename","document-move"],"backgroundTag":"file-not-found","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}