{"record":{"id":"e633709ed5e1e8c3","repo":"siyuan-note/siyuan","slug":"localized-message-from-conf-language-7-formatted-with-box","errorCode":null,"errorMessage":"localized message from Conf.Language(7) formatted with box.Name, path, err (remove failed)","messagePattern":"localized message from Conf\\.Language\\(7\\) formatted with box\\.Name, path, err \\(remove failed\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/box.go","lineNumber":546,"sourceCode":"\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)\n\tif err := filelock.Remove(filePath); err != nil {\n\t\tmsg := fmt.Sprintf(Conf.Language(7), box.Name, path, err)\n\t\tlogging.LogErrorf(\"remove [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) ListFiles(path string) (ret []*FileInfo) {\n\t// ListFiles 委托给 Ls，后者已有 validateBoxPath\n\tfis, _, err := box.Ls(path)\n\tif err != nil {\n\t\treturn\n\t}\n\tbox.listFiles(&fis, &ret)\n\treturn\n}\n\nfunc (box *Box) listFiles(files, ret *[]*FileInfo) {\n\tfor _, file := range *files {\n\t\tif file.isdir {","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/box.go#L528-L564","documentation":"Box.Remove deletes a file or document path inside a notebook via filelock.Remove. On failure it formats a localized message from Conf.Language(7) with box name, path, and OS error, logs the detail, and returns the message. Reached by removeDoc when deleting documents.","triggerScenarios":"Calling Box.Remove(path) (deleting a document/folder in the UI) when the OS remove fails: permission denied, path is a non-empty directory handled by the underlying remove semantics, file locked by another process, or read-only filesystem.","commonSituations":"Deleting documents while a sync client holds them open on Windows; workspace on a read-only or unmounted volume; process running as a user without delete permission on the data folder.","solutions":["Close programs (sync clients, editors) holding the file open","Verify write/delete permissions on <DataDir>/<boxID>/ and its contents","Ensure the workspace volume is mounted read-write","Check the kernel log for 'remove [path=...] failed' to obtain the underlying OS error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Go: confirm the path exists and is deletable\np := filepath.Join(util.DataDir, box.ID, path)\nif !util.IsExist(p) { return errors.New(\"nothing to remove\") }\ninfo, _ := os.Stat(p)\nif info != nil && info.IsDir() && !util.IsEmptyDir(p) { /* expect recursive remove */ }","typeGuard":null,"tryCatchPattern":"if err := box.Remove(path); err != nil {\n    // localized message; underlying OS error in kernel log 'remove [path=...] failed'\n    return err\n}","preventionTips":["Close apps holding documents open","Keep workspace volume writable and mounted","Verify permissions on the data directory"],"tags":["go","filesystem","delete","document"],"backgroundTag":"file-delete-failed","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"}