An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Fix pandoc export
Danielb2c0f3ea1f38
diff --git a/kernel/model/conf.go b/kernel/model/conf.goindex e5bb9f2683..637b10093f 100644--- a/kernel/model/conf.go+++ b/kernel/model/conf.go@@ -789,6 +789,7 @@ func clearCorruptedNotebooks() {func clearWorkspaceTemp() {os.RemoveAll(filepath.Join(util.TempDir, "bazaar"))os.RemoveAll(filepath.Join(util.TempDir, "export"))+ os.RemoveAll(filepath.Join(util.TempDir, "convert"))os.RemoveAll(filepath.Join(util.TempDir, "import"))os.RemoveAll(filepath.Join(util.TempDir, "repo"))os.RemoveAll(filepath.Join(util.TempDir, "os"))diff --git a/kernel/model/export.go b/kernel/model/export.goindex 5996c64f61..fe16a50cf6 100644--- a/kernel/model/export.go+++ b/kernel/model/export.go@@ -2071,18 +2071,11 @@ func exportPandocConvertZip(boxID, baseFolderName string, docPaths []string,}// 调用 Pandoc 进行格式转换- output, err := util.Pandoc(pandocFrom, pandocTo, writePath, md)+ err := util.Pandoc(pandocFrom, pandocTo, writePath, md)if nil != err {logging.LogErrorf("pandoc failed: %s", err)continue}-- if "odt" != pandocTo && "epub" != pandocTo && "rtf" != pandocTo {- if err := gulu.File.WriteFileSafer(writePath, gulu.Str.ToBytes(output), 0644); nil != err {- logging.LogErrorf("write export markdown file [%s] failed: %s", writePath, err)- continue- }- }}zipPath = exportFolder + ".zip"diff --git a/kernel/util/pandoc.go b/kernel/util/pandoc.goindex 845bb0484a..9c4884f180 100644--- a/kernel/util/pandoc.go+++ b/kernel/util/pandoc.go@@ -36,7 +36,7 @@ func ConvertPandoc(args ...string) (err error) {pandoc := exec.Command(PandocBinPath, args...)gulu.CmdAttr(pandoc)- dir := filepath.Join(WorkspaceDir, "temp", "convert", "pandoc")+ dir := filepath.Join(WorkspaceDir, "temp", "convert", "pandoc", gulu.Rand.String(7))if err = os.MkdirAll(dir, 0755); nil != err {logging.LogErrorf("mkdir [%s] failed: [%s]", dir, err)return@@ -50,31 +50,38 @@ func ConvertPandoc(args ...string) (err error) {return}-func Pandoc(from, to, o, content string) (ret string, err error) {+func Pandoc(from, to, o, content string) (err error) {if "" == from || "" == to || "md" == to {- ret = content+ return+ }++ dir := filepath.Join(WorkspaceDir, "temp", "convert", "pandoc", gulu.Rand.String(7))+ if err = os.MkdirAll(dir, 0755); nil != err {+ logging.LogErrorf("mkdir [%s] failed: [%s]", dir, err)+ return+ }+ tmpPath := filepath.Join(dir, gulu.Rand.String(7))+ if err = os.WriteFile(tmpPath, []byte(content), 0644); nil != err {+ logging.LogErrorf("write file failed: [%s]", err)return}args := []string{+ tmpPath,"--from", from,"--to", to,"--resource-path", filepath.Dir(o),"-s",- }-- if "" != o {- args = append(args, "-o", o)+ "-o", o,}pandoc := exec.Command(PandocBinPath, args...)gulu.CmdAttr(pandoc)- pandoc.Stdin = bytes.NewBufferString(content)output, err := pandoc.CombinedOutput()if nil != err {+ logging.LogErrorf("pandoc convert output [%s], error [%s]", string(output), err)return}- ret = string(output)return}