{"record":{"id":"99de803579149303","repo":"siyuan-note/siyuan","slug":"conf-language-371","errorCode":null,"errorMessage":"Conf.Language(371)","messagePattern":"Conf\\.Language\\(371\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/history.go","lineNumber":660,"sourceCode":"\nfunc RollbackNotebookHistory(historyPath string) (err error) {\n\thistoryPath, err = validateHistoryPath(historyPath)\n\tif err != nil {\n\t\treturn\n\t}\n\tboxID, err := validateNotebookHistoryPath(historyPath)\n\tif err != nil {\n\t\treturn\n\t}\n\tif _, loaded := boxLock.LoadOrStore(boxID, true); loaded {\n\t\treturn errors.New(Conf.Language(239))\n\t}\n\tdefer boxLock.Delete(boxID)\n\n\tfrom := historyPath\n\tto := filepath.Join(util.DataDir, boxID)\n\tif filelock.IsExist(to) {\n\t\treturn errors.New(Conf.Language(371))\n\t}\n\n\tif err = filelock.CopyNewtimes(from, to); err != nil {\n\t\tlogging.LogErrorf(\"copy file [%s] to [%s] failed: %s\", from, to, err)\n\t\treturn\n\t}\n\n\tIncSync()\n\tReloadFiletree()\n\tutil.PushMsg(Conf.Language(372), 3000)\n\treturn nil\n}\n\nfunc validateNotebookHistoryPath(historyPath string) (boxID string, err error) {\n\trel, err := filepath.Rel(util.HistoryDir, historyPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid notebook history path [%s]\", historyPath)\n\t}","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/history.go#L642-L678","documentation":"Before copying the historical notebook snapshot back into the workspace, RollbackNotebookHistory checks whether data/<boxID> already exists. If a notebook with that ID is present, the rollback is refused with the localized message Conf.Language(371) to avoid clobbering or merging into an existing notebook.","triggerScenarios":"Calling RollbackNotebookHistory for a deleted-notebook history entry while a notebook with the same boxID exists under data/ — e.g. the notebook was recreated or restored already, or only some documents were deleted so the notebook itself remains.","commonSituations":"Users deleting and recreating a notebook, then trying to roll back the deletion record; retrying a rollback that partially succeeded; restoring history after sync re-created the notebook.","solutions":["Remove or rename the existing notebook with that ID first if the historical copy should replace it","Roll back individual documents instead of the whole notebook if the notebook still exists","Choose a different history entry (before the notebook was recreated) or create a fresh notebook and copy content"],"exampleFix":"// before\nrollbackNotebookHistory(p) // data/<boxID> still exists -> error 371\n// after\nif (!filelock.IsExist(filepath.Join(util.DataDir, boxID))) { rollbackNotebookHistory(p) }","handlingStrategy":"validation","validationCode":"const boxID = parseBoxIDFromHistoryPath(p);\nif (fs.existsSync(path.join(dataDir, boxID))) { throw new Error('notebook already exists; choose doc-level rollback or remove it first'); }","typeGuard":null,"tryCatchPattern":"try { await rollbackNotebookHistory(p); } catch (e) { if (isNotebookExistsMessage(e)) { promptUserConflictResolution(boxID); } else { throw e; } }","preventionTips":["Check data/<boxID> existence before calling notebook rollback","Use document-level rollback when the notebook still exists","After sync re-creates a notebook, prefer merging content manually over whole-notebook rollback"],"tags":["history","notebook","conflict","rollback"],"backgroundTag":"file-already-exists","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"}