{"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":343,"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":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/repository.go#L325-L361","documentation":"Thrown by RollbackRepoSnapshotFile after it writes the decrypted snapshot payload to a temp file (path `from`) and loadTree() returns a nil tree. loadTree reads the file, decrypts it for encrypted notebooks, then runs dataparser.ParseJSONWithoutFix; here its error is discarded (`tree, _ := loadTree(...)`) so any read/decrypt/parse failure collapses into this single message. The literal string is misleading: the temp file usually exists, but its contents could not be parsed into a SiYuan block tree.","triggerScenarios":"Calling the rollback-snapshot-file API on a .sy whose decrypted content is corrupt/truncated, or whose decryption produced garbage (wrong/missing DEK cache evicted mid-operation), or when the temp dir (util.TempDir/repo/rollback) was concurrently cleaned. Also reachable if the just-written temp file was removed before loadTree re-reads it.","commonSituations":"Rolling back an old encrypted-notebook snapshot after the notebook state changed; partial snapshot data from an interrupted sync; concurrent history/repo cleanup tasks racing with rollback; a manually edited or half-downloaded snapshot object in the dejavu repo store.","solutions":["Inspect the kernel log: loadTree logs 'get data [path=%s] failed' or 'decrypt tree ... failed' just before this message — that line names the real cause (read error vs decrypt error vs parse error).","Verify the snapshot object is intact in the repo store and re-download it from cloud if it was partially transferred.","If the snapshot belongs to an encrypted notebook, confirm the notebook is unlocked and retry the rollback; an evicted/missing DEK makes decryption yield unparseable bytes.","Retry after ensuring no other history/repo cleanup or temp-dir prune is running concurrently."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate the file object before rollback: ensure it exists in the index\nif file == nil || file.Path == \"\" || !strings.HasSuffix(file.Path, \".sy\") {\n    return fmt.Errorf(\"invalid snapshot file for rollback\")\n}","typeGuard":null,"tryCatchPattern":"err := model.RollbackRepoSnapshotFile(fileID)\nif err != nil {\n    if strings.Contains(err.Error(), \"no such file or directory\") {\n        // snapshot payload unparseable/corrupt — surface to user, suggest re-download\n        util.PushErrMsg(\"Snapshot file is corrupt or unavailable, try re-downloading\", 5000)\n    }\n    return err\n}","preventionTips":["Do not prune util.TempDir/repo while a rollback is in progress.","Keep encrypted notebooks unlocked during snapshot rollback.","Treat the kernel log line preceding this error (loadTree read/decrypt/parse failure) as the real diagnostic."],"tags":["repo","snapshot","rollback","data-integrity"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}