{"record":{"id":"8a4f0bd0658c39c4","repo":"siyuan-note/siyuan","slug":"read-dir-s-failed-w","errorCode":null,"errorMessage":"read dir [%s] failed: %w","messagePattern":"read dir \\[(.+?)\\] failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":2745,"sourceCode":"\t\t\treturn fmt.Errorf(\"target ID [%s] must not be included in source IDs\", targetID)\n\t\t}\n\t\tif _, ok := seen[sourceID]; ok {\n\t\t\treturn fmt.Errorf(\"duplicate source ID [%s]\", sourceID)\n\t\t}\n\t\tseen[sourceID] = struct{}{}\n\t}\n\treturn nil\n}\n\nfunc isSortableDocument(tree *treenode.BlockTree) bool {\n\treturn nil != tree && tree.ID == tree.RootID && \"d\" == tree.Type && !IsBoxDoc(tree.BoxID, tree.RootID)\n}\n\nfunc loadSiblingCustomOrder(boxID, parentPath string, fullSortIDs map[string]int) (ret []string, err error) {\n\tabsParentPath := filepath.Join(util.DataDir, boxID, parentPath)\n\tfiles, err := os.ReadDir(absParentPath)\n\tif nil != err {\n\t\treturn nil, fmt.Errorf(\"read dir [%s] failed: %w\", absParentPath, err)\n\t}\n\tfor _, file := range files {\n\t\tif file.IsDir() || !strings.HasSuffix(file.Name(), \".sy\") {\n\t\t\tcontinue\n\t\t}\n\t\tid := strings.TrimSuffix(file.Name(), \".sy\")\n\t\tif !ast.IsNodeIDPattern(id) || (\"/\" == parentPath && id == boxID) {\n\t\t\tcontinue\n\t\t}\n\t\tret = append(ret, id)\n\t}\n\tsort.Slice(ret, func(i, j int) bool {\n\t\tleftSort, rightSort := fullSortIDs[ret[i]], fullSortIDs[ret[j]]\n\t\tif leftSort != rightSort {\n\t\t\treturn leftSort < rightSort\n\t\t}\n\t\tleftTime, rightTime := util.TimeFromID(ret[i]), util.TimeFromID(ret[j])\n\t\tif leftTime != rightTime {","sourceCodeStart":2727,"sourceCodeEnd":2763,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/file.go#L2727-L2763","documentation":"loadSiblingCustomOrder reads the parent directory on disk (under workspace data/<boxID>/<parentPath>) with os.ReadDir to enumerate sibling .sy files before applying the custom order. This error wraps the underlying OS error when that directory cannot be read — the file system entry is missing, unreadable, or is not a directory. The absolute path and original error are embedded in the message.","triggerScenarios":"Reordering docs whose parent folder no longer exists on disk (deleted externally or by an unsynced/corrupt sync state); the parent path points to a file instead of a directory; workspace data directory moved or on a detached/unmounted volume; permission problems on the data directory.","commonSituations":"Notebook data synced from another machine with missing folders; user manually deleted or moved folders inside the workspace while the kernel was running; external drive/network volume disconnected; path casing or workspace misconfiguration pointing at the wrong data root.","solutions":["Verify the directory printed in the error exists in the workspace data folder and is readable; restore it from sync/backup if missing","Check notebook consistency (rebuild/reindex the notebook from the SiYuan UI) so paths match disk state","Fix file system permissions on the workspace data directory","Confirm the storage volume is mounted/available and the workspace path in the config is correct"],"exampleFix":"// before\nabsParentPath := filepath.Join(util.DataDir, boxID, parentPath)\nfiles, err := os.ReadDir(absParentPath) // err ignored upstream -> wrapped error\n// after\nabsParentPath := filepath.Join(util.DataDir, boxID, parentPath)\nif _, statErr := os.Stat(absParentPath); statErr != nil {\n    log.Warnf(\"parent path missing, skip reorder: %v\", statErr)\n    return\n}\nfiles, err := os.ReadDir(absParentPath)","handlingStrategy":"try-catch","validationCode":"absParentPath := filepath.Join(util.DataDir, boxID, parentPath)\nif info, err := os.Stat(absParentPath); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"parent path unavailable: %s\", absParentPath)\n}","typeGuard":"func dirExists(path string) bool {\n    info, err := os.Stat(path)\n    return err == nil && info.IsDir()\n}","tryCatchPattern":"if _, err := os.ReadDir(absParentPath); err != nil {\n    log.Warnf(\"cannot read %s: %v; skipping reorder\", absParentPath, err)\n    return\n}","preventionTips":["Verify the printed absolute path exists and is a directory on the workspace volume","Keep the workspace on a reliably mounted storage location; avoid removable/network volumes mid-session","Do not delete or move folders under data/ externally while the kernel runs; use the app or reindex after external changes","Fix data-directory permissions for the user running the kernel"],"tags":["filesystem","io","directory","oserror"],"backgroundTag":"directory-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"}