{"record":{"id":"56e66e1578feb753","repo":"siyuan-note/siyuan","slug":"errors-new-msg-with-conf-language-7-template-re","errorCode":null,"errorMessage":"errors.New(msg) with Conf.Language(7) template: remove failure message shown to user","messagePattern":"errors\\.New\\(msg\\) with Conf\\.Language\\(7\\) template: remove failure message shown to user","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/box.go","lineNumber":542,"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":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/box.go#L524-L560","documentation":"Box.Remove deletes a file/directory inside a notebook via filelock.Remove (called from removeDoc). On failure it formats the localized template Conf.Language(7) and returns errors.New(msg) with the OS error embedded.","triggerScenarios":"Deleting a document/asset when the file is already gone, locked by another process, or the process lacks delete permission on the file or its parent directory.","commonSituations":"Windows file lock from an indexer/antivirus or an open editor; read-only volume; doc already removed by another client; parent directory permission changes.","solutions":["Check the OS error text in the message for the exact cause","Close programs holding the file (editors, previews) and retry","Fix permissions on the file or its parent directory","If the target is already gone, refresh the doc tree — the deletion may already be applied"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(filePath); os.IsNotExist(err) { return nil } // already deleted","typeGuard":null,"tryCatchPattern":"if err := box.Remove(path); err != nil { if !os.IsNotExist(cause) { showErrorToUser(err.Error()) } }","preventionTips":["Close editors/previews holding files before deleting","Exclude the data dir from file lockers/indexers","Refresh the doc tree when a delete reports a missing file"],"tags":["filesystem","delete","user-facing"],"backgroundTag":"permission-denied","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}