{"record":{"id":"163197117889130b","repo":"siyuan-note/siyuan","slug":"localized-message-from-conf-language-6-formatted-with-box-163197","errorCode":null,"errorMessage":"localized message from Conf.Language(6) formatted with box.Name, path, err (mkdir all failed)","messagePattern":"localized message from Conf\\.Language\\(6\\) formatted with box\\.Name, path, err \\(mkdir all failed\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/box.go","lineNumber":504,"sourceCode":"\t\treturn err\n\t}\n\tif err := os.Mkdir(filepath.Join(util.DataDir, box.ID, path), 0755); err != nil {\n\t\tmsg := fmt.Sprintf(Conf.Language(6), box.Name, path, err)\n\t\tlogging.LogErrorf(\"mkdir [path=%s] in box [%s] failed: %s\", path, box.ID, err)\n\t\treturn errors.New(msg)\n\t}\n\tIncSync()\n\treturn nil\n}\n\nfunc (box *Box) MkdirAll(path string) error {\n\tif _, err := box.validateBoxPath(path); err != nil {\n\t\treturn err\n\t}\n\tif err := os.MkdirAll(filepath.Join(util.DataDir, box.ID, path), 0755); err != nil {\n\t\tmsg := fmt.Sprintf(Conf.Language(6), box.Name, path, err)\n\t\tlogging.LogErrorf(\"mkdir all [path=%s] in box [%s] failed: %s\", path, box.ID, err)\n\t\treturn errors.New(msg)\n\t}\n\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)","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/box.go#L486-L522","documentation":"Box.MkdirAll creates a directory tree inside a notebook. On os.MkdirAll failure it formats a localized message via Conf.Language(6) with box name, path, and the OS error, logs the detail, and returns the message. Called internally by moveDoc when recreating destination directories during a document move.","triggerScenarios":"Calling Box.MkdirAll(path) (also reached by moving a document whose target directory does not exist) when the OS mkdir -p fails: permission denied, path component is a file, read-only volume, or illegal characters in a path segment.","commonSituations":"moveDoc targeting a path where an intermediate segment exists as a file; restoring a notebook onto a read-only disk; long-path limits on Windows exceeding MAX_PATH.","solutions":["Verify no file exists with the same name as an intermediate path segment","Ensure the notebook directory is writable and the volume mounted","Shorten the target path on Windows or enable long-path support","Check the kernel log for the 'mkdir all [path=...] failed' entry to get the exact OS error"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Go: ensure no intermediate segment is a regular file\nfor seg := path; seg != \".\" && seg != \"/\" && seg != \"\"; seg = filepath.Dir(seg) {\n    if util.IsExist(filepath.Join(util.DataDir, box.ID, seg)) &&\n        !gulu.File.IsDir(filepath.Join(util.DataDir, box.ID, seg)) {\n        return fmt.Errorf(\"%s is a file, not a directory\", seg)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := box.MkdirAll(path); err != nil {\n    // localized message; see kernel log 'mkdir all [path=...] failed'\n    return err\n}","preventionTips":["Keep path segments free of illegal characters","Avoid very deep/long paths on Windows","Ensure intermediate names are not used by files"],"tags":["go","filesystem","mkdir","document-move"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}