{"record":{"id":"1015b55e45f482c9","repo":"siyuan-note/siyuan","slug":"cannot-disable-encrypted-notebooks-deleted-notebo","errorCode":null,"errorMessage":"Cannot disable encrypted notebooks: deleted-notebook history still depends on the current key backup. Clear that history first","messagePattern":"Cannot disable encrypted notebooks: deleted-notebook history still depends on the current key backup\\. Clear that history first","errorType":"http","errorClass":null,"httpStatus":200,"severity":"error","filePath":"kernel/model/crypto.go","lineNumber":1087,"sourceCode":"\tnotebookCryptoMu.Lock()\n\tdefer notebookCryptoMu.Unlock()\n\n\t// 检查是否还有加密笔记本（含 conf 损坏但存在备份的）\n\tids, listErr := listAllEncryptedBoxIDs()\n\tif listErr != nil {\n\t\treturn fmt.Errorf(\"list encrypted notebooks failed: %w\", listErr)\n\t}\n\tif len(ids) > 0 {\n\t\treturn errors.New(\"cannot disable encrypted notebook feature while encrypted notebooks exist, remove them first\")\n\t}\n\t// 检查历史目录中是否存在已删除加密笔记本的历史快照：其恢复仍依赖当前 MasterSalt/KEKVerifier，\n\t// 删除备份前必须先清除这些历史（详见设计 §19）\n\thasHistory, historyErr := scanEncryptedNotebookHistory()\n\tif historyErr != nil {\n\t\treturn fmt.Errorf(\"check encrypted notebook history failed: %w\", historyErr)\n\t}\n\tif hasHistory {\n\t\treturn errors.New(Conf.Language(323))\n\t}\n\n\tConf.m.Lock()\n\tConf.NotebookCrypto.Enabled = false\n\tConf.NotebookCrypto.MasterSalt = nil\n\tConf.NotebookCrypto.KEKVerifier = nil\n\tConf.NotebookCrypto.VerifierNonce = nil\n\tConf.m.Unlock()\n\n\tConf.Save()\n\tremoveNotebookCryptoBackup() // 禁用时清理备份，避免残留旧密钥材料\n\tIncSync()\n\treturn nil\n}\n\n// restoreNotebookCryptoConfigFromBackup 把备份里的 NotebookCrypto 配置装回本机 conf.json（不需主密码）。\n// 用于数据同步/导入 Data.zip 后：备份文件随 DataDir 到达新设备，但本机 conf.json 的 NotebookCrypto 还是空的。\n// 此时把 salt/verifier/KDFParams 装回并置 Enabled=true，让 UI 显示\"已启用\"，笔记本显示为锁定（解锁仍需主密码）。","sourceCodeStart":1069,"sourceCodeEnd":1105,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/crypto.go#L1069-L1105","documentation":"Error \"Cannot disable encrypted notebooks: deleted-notebook history still depends on the current key backup. Clear that history first\" thrown in siyuan-note/siyuan.","triggerScenarios":"Thrown at kernel/model/crypto.go:1087 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Clear the history entries of deleted encrypted notebooks first (History - clear the affected entries), then disable the encrypted notebook feature.","Disabling now would permanently lock those history snapshots because they still depend on the current key backup."],"exampleFix":"Clear the deleted-notebook history (History - clear) for encrypted notebooks so it no longer depends on the current key backup, then disable the feature.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}