{"record":{"id":"c5d671ef22292988","repo":"siyuan-note/siyuan","slug":"encrypted-notebook-feature-is-already-enabled","errorCode":null,"errorMessage":"Encrypted notebook feature is already enabled","messagePattern":"Encrypted notebook feature is already enabled","errorType":"http","errorClass":null,"httpStatus":200,"severity":"error","filePath":"kernel/model/crypto.go","lineNumber":987,"sourceCode":"\treturn EnableEncryptedNotebook(password)\n}\n\n// EnableEncryptedNotebook 启用加密笔记本功能：生成 MasterSalt、派生 KEK、写入校验值并持久化。\n// 重复调用（已启用）返回错误，避免覆盖现有加密笔记本的密钥参数。\n// KEK 不缓存——启用后用户需对每个加密笔记本单独调 UnlockBox 解锁。\nfunc EnableEncryptedNotebook(password string) error {\n\tif len(password) == 0 {\n\t\treturn errors.New(\"password must not be empty\")\n\t}\n\n\tnotebookCryptoMu.Lock()\n\tdefer notebookCryptoMu.Unlock()\n\n\tConf.m.RLock()\n\tcurrent := *Conf.NotebookCrypto\n\tConf.m.RUnlock()\n\tif current.Enabled && notebookCryptoConfigurationComplete(&current) {\n\t\treturn errors.New(Conf.Language(312))\n\t}\n\n\thasEncrypted, listErr := hasEncryptedNotebook()\n\tif listErr != nil {\n\t\treturn fmt.Errorf(\"list encrypted notebooks failed: %w\", listErr)\n\t}\n\thasHistory, historyErr := scanEncryptedNotebookHistory()\n\tif historyErr != nil {\n\t\treturn fmt.Errorf(\"check encrypted notebook history failed: %w\", historyErr)\n\t}\n\thasBackup := filelock.IsExist(dataCryptoBackupPath())\n\tif hasEncrypted || hasHistory || hasBackup {\n\t\t// 现存笔记本、已删除笔记本历史或全局备份均表示已有密钥域，必须恢复并认证，不能生成新 MasterSalt。\n\t\tkek, restoreErr := tryRestoreNotebookCryptoFromBackupLocked(password)\n\t\tif kek != nil {\n\t\t\tzeroAndClear(kek)\n\t\t}\n\t\tif restoreErr != nil {","sourceCodeStart":969,"sourceCodeEnd":1005,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/crypto.go#L969-L1005","documentation":"Error \"Encrypted notebook feature is already enabled\" thrown in siyuan-note/siyuan.","triggerScenarios":"Thrown at kernel/model/crypto.go:987 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The encrypted notebook feature is already enabled; no action is needed.","If you intended to change the master password, use the change master password function instead of enabling again.","If you believe the state is wrong (e.g. config was reset), use the recovery flow with your original master password instead of re-enabling."],"exampleFix":"Check the enabled flag before invoking the enable operation; disable the enable action in the UI when the feature is already active instead of reaching this error.","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"}