Skip to content

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

:recycle: kernel/model/export: refactor manual loop with slices.Contains and manual copying with maps.Copy (#17268)

iliya253b64fe3ae7
diff --git a/kernel/model/export.go b/kernel/model/export.go
index b60cb2acb8..e0895cc8f2 100644
--- a/kernel/model/export.go
+++ b/kernel/model/export.go
@@ -22,6 +22,7 @@ import (
"encoding/csv"
"errors"
"fmt"
+ "maps"
"net/http"
"net/url"
"os"
@@ -1352,11 +1353,8 @@ func processPDFWatermark(pdfCtx *model.Context, watermark bool) {
builtInFontNames = append(builtInFontNames, f)
}
- for _, font := range builtInFontNames {
- if font == m["fontname"] {
- useDefaultFont = false
- break
- }
+ if slices.Contains(builtInFontNames, m["fontname"]) {
+ useDefaultFont = false
}
}
}
@@ -1947,9 +1945,7 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (
}
// 将引用树合并到选择树中,以便后面一次性导出资源文件
- for treeID, tree := range refTrees {
- trees[treeID] = tree
- }
+ maps.Copy(trees, refTrees)
// 导出引用的资源文件
assetPathMap, err := allAssetAbsPaths()