Skip to content

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

:memo: Fix doc: db delete not close, pre-lock save, remove fallback description https://github.com/siyuan-note/siyuan/issues/18034

Daniele3f64f291e04
diff --git a/docs/ENCRYPTED-NOTEBOOK.md b/docs/ENCRYPTED-NOTEBOOK.md
index ddc2761d98..16b2312683 100644
--- a/docs/ENCRYPTED-NOTEBOOK.md
+++ b/docs/ENCRYPTED-NOTEBOOK.md
@@ -34,7 +34,7 @@ Implement an "encrypted notebook" in SiYuan — a special notebook whose `.sy` d
|---|---|---|
| **Create** | Anytime, no restrictions | Must first enable encryption (set master password); creating requires verifying master password |
| **Open (Mount)** | Direct open | Must first enter master password to unlock (~1s Argon2id each time); DEK enters memory |
-| **Close (Unmount)** | Closing makes it invisible | Close = lock (DEK cleared + encrypted SQLite database closed + all plaintext caches cleared) |
+| **Close (Unmount)** | Closing makes it invisible | Close = lock (DEK cleared + encrypted SQLite database deleted + all plaintext caches cleared) |
| **After restart** | Keeps last open state | Force-closed; must re-enter master password to unlock |
| **.sy files** | Plaintext JSON on disk | AES-256-GCM ciphertext on disk, transparently decrypted on read |
| **assets files** | Plaintext binary, original filename | AES-256-GCM ciphertext, filename desensitized, original name encrypted |
@@ -190,6 +190,7 @@ Encrypted-notebook operations (dedicated read path, with boxID):
```
File history:
edit triggers history generation → ciphertext .sy copied verbatim to history dir
+ auto-generated before close/exit → ensures history is captured even after locking
history index → content left empty (ciphertext not indexed for search)
view history → decrypt by path boxID (notebook must be unlocked)
roll back → decrypt history → load tree → WriteTree auto-encrypts on write-back
@@ -231,7 +232,7 @@ Encrypted notebooks forbid moving documents across the encrypted boundary (norma
| Create | File panel "more" menu → "New encrypted notebook" → enter name + master password → auto-unlock and open |
| Icon | Shows lock icon when closed (locked); restores user emoji when opened (unlocked) |
| Unlock | Click a closed encrypted notebook → master-password prompt (🔓 Unlock xxx) → wait ~1s → opens |
-| Lock | Equals close (DEK cleared + encrypted SQLite database closed + all plaintext caches cleared) |
+| Lock | Equals close (DEK cleared + encrypted SQLite database deleted + all plaintext caches cleared). Unsaved edits and file history are automatically saved before locking |
| Change password | Settings → Access authorization → "Change master password" |
| Move document | Normal within an encrypted box or between normal boxes; cross-boundary (normal↔encrypted) rejected with a prompt |
| Doc to heading | Cross-boundary rejected with a prompt |
diff --git a/docs/ENCRYPTED-NOTEBOOK.zh-CN.md b/docs/ENCRYPTED-NOTEBOOK.zh-CN.md
index 55338367c0..b66c11f8de 100644
--- a/docs/ENCRYPTED-NOTEBOOK.zh-CN.md
+++ b/docs/ENCRYPTED-NOTEBOOK.zh-CN.md
@@ -34,7 +34,7 @@
|---|---|---|
| **创建** | 随时创建,无限制 | 需先启用加密功能(设主密码),创建时需验证主密码 |
| **打开(Mount)** | 直接打开 | 需先输主密码解锁(每次 ~1 秒 Argon2id),DEK 进内存 |
-| **关闭(Unmount)** | 关闭即不可见 | 关闭 = 锁定(DEK 清除 + 加密 SQLite 数据库 关闭 + 所有明文缓存清空) |
+| **关闭(Unmount)** | 关闭即不可见 | 关闭 = 锁定(DEK 清除 + 加密 SQLite 数据库 删除 + 所有明文缓存清空) |
| **重启后** | 保持上次打开状态 | 强制关闭,需重新输主密码解锁 |
| **.sy 文件** | 明文 JSON 落盘 | AES-256-GCM 密文落盘,读时透明解密 |
| **assets 文件** | 明文二进制,原始文件名 | AES-256-GCM 密文,文件名脱敏,原始名加密存储 |
@@ -190,6 +190,7 @@ MasterSalt 是 KEK 派生的全局根基——主密码 + MasterSalt 经 Argon2i
```
文件历史:
编辑触发历史生成 → 密文 .sy 原样拷到历史目录
+ 关闭/退出前自动生成历史 → 确保锁定后定时器无法生成时不丢历史
历史索引 → content 留空(密文不进搜索索引)
查看历史 → 按路径 boxID 解密(需笔记本已解锁)
回滚 → 解密历史 → 加载 tree → WriteTree 自动加密写回
@@ -231,7 +232,7 @@ MasterSalt 是 KEK 派生的全局根基——主密码 + MasterSalt 经 Argon2i
| 创建 | 文件面板"更多"菜单 → "新建加密笔记本" → 输名字 + 主密码 → 自动解锁并打开 |
| 图标 | 关闭(锁定)时显示锁图标;打开(解锁)后恢复用户 emoji |
| 解锁 | 点已关闭的加密笔记本 → 弹主密码框(🔓 解锁 xxx)→ 等 ~1 秒 → 打开 |
-| 锁定 | 等于关闭(DEK 清除 + db 关闭 + 所有明文缓存清空) |
+| 锁定 | 等于关闭(DEK 清除 + 加密 SQLite 数据库 删除 + 所有明文缓存清空)。关闭前会自动保存未写入的编辑和文件历史 |
| 改密 | 设置 → 访问授权 → "修改主密码" |
| 移动文档 | 加密 box 内部或普通 box 之间正常移动;跨加密边界(普通↔加密)被拒绝并提示 |
| 文档转标题 | 跨加密边界被拒绝并提示 |