{"record":{"id":"28ac2f6f12625392","repo":"siyuan-note/siyuan","slug":"no-such-file-or-directory-s","errorCode":null,"errorMessage":"no such file or directory: %s","messagePattern":"no such file or directory: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/repository.go","lineNumber":326,"sourceCode":"\t\t}\n\t\tboxID = box.ID\n\n\t\tvar destPath, parentHPath string\n\t\trootID := util.GetTreeID(file.Path)\n\t\tworkingDoc := treenode.GetBlockTree(rootID)\n\t\tif needResetTree {\n\t\t\tworkingDoc = nil\n\t\t}\n\t\tdestPath, parentHPath, err = getRollbackDockPath(boxID, file.Path, workingDoc)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\n\t\ttree, _ := loadTree(from, util.NewLute())\n\t\tif nil == tree {\n\t\t\tmsg := fmt.Sprintf(\"no such file or directory: %s\", from)\n\t\t\tlogging.LogError(msg)\n\t\t\terr = errors.New(msg)\n\t\t\treturn\n\t\t}\n\n\t\ttree.Box = boxID\n\t\ttree.Path = filepath.ToSlash(strings.TrimPrefix(destPath, util.DataDir+string(os.PathSeparator)+boxID))\n\t\ttree.HPath = parentHPath + \"/\" + tree.Root.IALAttr(\"title\")\n\t\tif needResetTree {\n\t\t\tresetTree(tree, \"\", true)\n\t\t}\n\n\t\tif nil != workingDoc && \"d\" == workingDoc.Type {\n\t\t\tworkingDocPath := filepath.Join(util.DataDir, boxID, workingDoc.Path)\n\t\t\tif err = filelock.Remove(workingDocPath); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlogging.LogInfof(\"removed working doc file [%s]\", workingDocPath)\n\t\t}\n\t\tif nil != workingDoc {","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/repository.go#L308-L344","documentation":"RollbackRepoSnapshotFile fails with 'no such file or directory: <temp path>' when the snapshot .sy content was written to the temp rollback directory but loadTree cannot parse it into a valid tree (nil tree). Although the message says 'no such file or directory', the usual cause is a corrupt/empty/unparseable snapshot file rather than a genuinely missing temp file.","triggerScenarios":"repoFileRollback on a .sy file whose decrypted content in Temp/repo/rollback/... fails to load as a Kramdown tree — empty data, truncated snapshot, or content that Lute cannot parse as a document.","commonSituations":"Snapshot created by an older SiYuan version with a format the current Lute rejects; interrupted sync leaving a truncated snapshot; repo corruption after disk failure or manual tampering with .siyuan/repo; a snapshot of an empty/invalid document.","solutions":["Inspect the temp file content printed in the log message; if empty or truncated, the snapshot is corrupt","Try rolling back to an earlier snapshot of the same document instead","Run repo consistency check / re-sync (rebuild snapshots) if the repo was corrupted by disk failure","Restore the workspace from backup if multiple snapshots fail to load","Report to maintainers with the snapshot path if a valid-looking snapshot consistently fails to load (possible parser regression)"],"exampleFix":"// no code fix — pick a healthy snapshot\n// before: rollback to corrupt snapshot S_N fails\n// after: list history and roll back to the previous good snapshot\nPOST /api/repo/rollbackRepoFile {\"id\": \"<earlierSnapshotFileID>\"}","handlingStrategy":"retry","validationCode":"// check the snapshot file is a parseable document before rollback\nconst raw = await fetchPost(\"/api/repo/getRepoFile\", {id: fileID});\nif (!raw.data || !String(raw.data.content).trim()) {\n  throw new Error(\"snapshot content is empty/corrupt; choose another snapshot\");\n}","typeGuard":null,"tryCatchPattern":"if err := model.RollbackRepoSnapshotFile(fileID); err != nil {\n    if strings.HasPrefix(err.Error(), \"no such file or directory:\") {\n        // snapshot unparseable — pick an earlier snapshot or rebuild repo\n    }\n    return err\n}","preventionTips":["Keep multiple snapshots per document so a corrupt one can be skipped","Avoid interrupting sync/index operations that write snapshots","Do not hand-edit files under .siyuan/repo","After disk errors, run repo consistency/rebuild before using history rollback"],"tags":["rollback","corruption","snapshot","parse"],"backgroundTag":"file-not-found","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"}