An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lock: Scope PDF preview temp exports and embedded assets under boxID #18034
Daniel01d3240b1935
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.tsindex dfabc7b795..ecc35ba154 100644--- a/app/src/protyle/export/index.ts+++ b/app/src/protyle/export/index.ts@@ -697,7 +697,7 @@ ${getIconScript(servePath)}</script>${getSnippetJS()}</body></html>`;- fetchPost("/api/export/exportTempContent", {content: html}, (response) => {+ fetchPost("/api/export/exportTempContent", {content: html, id}, (response) => {ipcRenderer.send(Constants.SIYUAN_EXPORT_NEWWINDOW, response.data.url);});};diff --git a/kernel/api/export.go b/kernel/api/export.goindex 5b991ae819..59fe813e6d 100644--- a/kernel/api/export.go+++ b/kernel/api/export.go@@ -638,11 +638,21 @@ func exportTempContent(c *gin.Context) {return}- var content string- if !util.ParseJsonArgs(arg, ret, util.BindJsonArg("content", &content, true, false)) {+ var content, id string+ if !util.ParseJsonArgs(arg, ret,+ util.BindJsonArg("content", &content, true, false),+ util.BindJsonArg("id", &id, false, false),+ ) {return}- tmpExport := filepath.Join(util.TempDir, "export", "temp")+ tmpExport := filepath.Join(util.TempDir, "export")+ // 加密笔记本的临时导出归入 boxID 子目录,确保 LockBox 清理和服务端校验锁定状态+ if id != "" {+ if bt := treenode.GetBlockTree(id); bt != nil && model.IsEncryptedBox(bt.BoxID) {+ tmpExport = filepath.Join(tmpExport, bt.BoxID)+ }+ }+ tmpExport = filepath.Join(tmpExport, "temp")if err := os.MkdirAll(tmpExport, 0755); err != nil {ret.Code = 1ret.Msg = err.Error()@@ -656,7 +666,19 @@ func exportTempContent(c *gin.Context) {ret.Data = map[string]any{"closeTimeout": 7000}return}- urlPath := path.Join("/export/temp/", filepath.Base(p))+ baseName := filepath.Base(p)+ urlPath := "/export/"+ if boxID := func() string {+ if id != "" {+ if bt := treenode.GetBlockTree(id); bt != nil && model.IsEncryptedBox(bt.BoxID) {+ return bt.BoxID+ }+ }+ return ""+ }(); boxID != "" {+ urlPath += boxID + "/"+ }+ urlPath = path.Join(urlPath, "temp", baseName)ret.Data = map[string]any{"url": util.ServerURL.Scheme + "://" + util.LocalHost + ":" + util.ServerPort + urlPath,}diff --git a/kernel/model/export.go b/kernel/model/export.goindex 6f8141eccf..18fc286eb0 100644--- a/kernel/model/export.go+++ b/kernel/model/export.go@@ -1630,7 +1630,13 @@ func processPDFLinkEmbedAssets(pdfCtx *model.Context, assetDests []string, boxIDlogging.LogWarnf("read encrypted asset [%s] failed: %s", sourceURI, readErr)continue}- embedPath = filepath.Join(util.TempDir, "export", "pdf-assets", gulu.Rand.String(7)+"-"+filepath.Base(AssetPathWithoutQuery(sourceURI)))+ // 加密笔记本的临时资源归入 boxID 子目录,确保 LockBox 清理和服务端校验锁定状态+ pdfAssetsDir := filepath.Join(util.TempDir, "export", assetBoxID, "pdf-assets")+ if mkErr := os.MkdirAll(pdfAssetsDir, 0755); mkErr != nil {+ logging.LogWarnf("mkdir pdf-assets [%s] failed: %s", pdfAssetsDir, mkErr)+ continue+ }+ embedPath = filepath.Join(pdfAssetsDir, gulu.Rand.String(7)+"-"+filepath.Base(AssetPathWithoutQuery(sourceURI)))if writeErr := filelock.WriteFile(embedPath, plain); nil != writeErr {logging.LogWarnf("write temp embedded asset [%s] failed: %s", embedPath, writeErr)continue