Skip to content

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

:rotating_light: disable export/history/import for encrypted notebooks (stage 7) #18034

Daniele959de43169a
diff --git a/kernel/model/export.go b/kernel/model/export.go
index f13bfc7379..62f59cc113 100644
--- a/kernel/model/export.go
+++ b/kernel/model/export.go
@@ -500,12 +500,20 @@ func ExportSystemLog() (zipPath string) {
}
func ExportNotebookSY(id string) (zipPath string) {
+ // 加密笔记本不支持导出,避免密文 .sy 流出后无法解读
+ if IsEncryptedBox(id) {
+ return
+ }
zipPath = exportBoxSYZip(id)
return
}
func ExportSYs(ids []string) (zipPath string) {
block := treenode.GetBlockTree(ids[0])
+ // 加密笔记本不支持导出
+ if nil != block && IsEncryptedBox(block.BoxID) {
+ return
+ }
box := Conf.Box(block.BoxID)
baseFolderName := path.Base(block.HPath)
if "." == baseFolderName {
diff --git a/kernel/model/history.go b/kernel/model/history.go
index 007e518c56..d612fa7f53 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -70,6 +70,10 @@ func GenerateFileHistory() {
// 生成文档历史
for _, box := range Conf.GetOpenedBoxes() {
+ // 加密笔记本不生成历史(历史目录不加密,密文 .sy 写进去也无意义)
+ if IsEncryptedBox(box.ID) {
+ continue
+ }
box.generateDocHistory0()
}
@@ -857,6 +861,10 @@ func CreateDocHistory(id string) (err error) {
}
func generateTreeHistory(tree *parse.Tree, historyDir string) {
+ // 加密笔记本不生成历史
+ if IsEncryptedBox(tree.Box) {
+ return
+ }
historyPath := filepath.Join(historyDir, tree.Box, tree.Path)
var err error
if err = os.MkdirAll(filepath.Dir(historyPath), 0755); err != nil {
diff --git a/kernel/model/import.go b/kernel/model/import.go
index 575ba20244..eaf9e01fbb 100644
--- a/kernel/model/import.go
+++ b/kernel/model/import.go
@@ -108,6 +108,11 @@ func HTML2Tree(htmlStr string, luteEngine *lute.Lute) (tree *parse.Tree, withMat
}
func ImportSY(zipPath, boxID, toPath string) (err error) {
+ // 加密笔记本不支持导入(导入的 .sy 是明文,落到加密目录会导致读取失败)
+ if IsEncryptedBox(boxID) {
+ err = errors.New("import to encrypted notebook is not supported")
+ return
+ }
util.PushEndlessProgress(Conf.Language(73))
defer util.ClearPushProgress(100)
@@ -769,6 +774,11 @@ func ImportData(zipPath string) (err error) {
}
func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
+ // 加密笔记本不支持导入
+ if IsEncryptedBox(boxID) {
+ err = errors.New("import to encrypted notebook is not supported")
+ return
+ }
util.PushEndlessProgress(Conf.Language(73))
defer func() {
util.PushClearProgress()