Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:lock: Auto-generate notebook crypt backup on unlock if missing https://github.com/siyuan-note/siyuan/issues/18034

Daniel5e4f41101515
diff --git a/kernel/model/crypto.go b/kernel/model/crypto.go
index 9ceca7e15e..a8f712cb29 100644
--- a/kernel/model/crypto.go
+++ b/kernel/model/crypto.go
@@ -513,6 +513,13 @@ func UnlockBox(boxID string, password string, boxEnc *conf.BoxEncryption) error
return err
}
cachedDEKs[boxID] = dek
+
+ // 确保备份存在(首次解锁或之前未成功写入备份时自动生成),便于 conf 损坏恢复
+ if !filelock.IsExist(notebookCryptBackupPath(boxID)) {
+ if err = writeNotebookCryptBackup(boxID, boxEnc); err != nil {
+ logging.LogWarnf("write notebook crypt backup [%s] failed: %s", boxID, err)
+ }
+ }
return nil
}