🎨 Windoar arm64 and Linux arm64 no longer packing pandoc https://github.com/siyuan-note/siyuan/issues/11649

This commit is contained in:
Daniel 2024-06-05 11:50:16 +08:00
parent 939b128e51
commit f9317ce744
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 26 additions and 9 deletions

View file

@ -71,5 +71,3 @@ extraResources:
- from: "src/assets/fonts" - from: "src/assets/fonts"
to: "appearance/fonts" to: "appearance/fonts"
filter: "!**/{.DS_Store}" filter: "!**/{.DS_Store}"
- from: "pandoc/pandoc-windows-amd64.zip"
to: "pandoc.zip"

View file

@ -64,5 +64,3 @@ extraResources:
- from: "src/assets/fonts" - from: "src/assets/fonts"
to: "appearance/fonts" to: "appearance/fonts"
filter: "!**/{.DS_Store}" filter: "!**/{.DS_Store}"
- from: "pandoc/pandoc-linux-amd64.zip"
to: "pandoc.zip"

View file

@ -22,6 +22,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime"
"strings" "strings"
"github.com/88250/gulu" "github.com/88250/gulu"
@ -29,9 +30,11 @@ import (
"github.com/siyuan-note/logging" "github.com/siyuan-note/logging"
) )
var ErrPandocNotFound = errors.New("not found executable pandoc")
func ConvertPandoc(dir string, args ...string) (path string, err error) { func ConvertPandoc(dir string, args ...string) (path string, err error) {
if "" == PandocBinPath || ContainerStd != Container { if "" == PandocBinPath || ContainerStd != Container {
err = errors.New("not found executable pandoc") err = ErrPandocNotFound
return return
} }
@ -55,6 +58,11 @@ func ConvertPandoc(dir string, args ...string) (path string, err error) {
} }
func Pandoc(from, to, o, content string) (err error) { func Pandoc(from, to, o, content string) (err error) {
if "" == PandocBinPath || ContainerStd != Container {
err = ErrPandocNotFound
return
}
if "" == from || "" == to || "md" == to { if "" == from || "" == to || "md" == to {
if err = gulu.File.WriteFileSafer(o, []byte(content), 0644); nil != err { if err = gulu.File.WriteFileSafer(o, []byte(content), 0644); nil != err {
logging.LogErrorf("write export markdown file [%s] failed: %s", o, err) logging.LogErrorf("write export markdown file [%s] failed: %s", o, err)
@ -123,9 +131,15 @@ func InitPandoc() {
defer eventbus.Publish(EvtConfPandocInitialized) defer eventbus.Publish(EvtConfPandocInitialized)
if gulu.OS.IsWindows() { if gulu.OS.IsWindows() {
if "amd64" == runtime.GOARCH {
PandocBinPath = filepath.Join(pandocDir, "bin", "pandoc.exe") PandocBinPath = filepath.Join(pandocDir, "bin", "pandoc.exe")
} else if gulu.OS.IsDarwin() || gulu.OS.IsLinux() { }
} else if gulu.OS.IsDarwin() {
PandocBinPath = filepath.Join(pandocDir, "bin", "pandoc") PandocBinPath = filepath.Join(pandocDir, "bin", "pandoc")
} else if gulu.OS.IsLinux() {
if "amd64" == runtime.GOARCH {
PandocBinPath = filepath.Join(pandocDir, "bin", "pandoc")
}
} }
pandocVer := getPandocVer(PandocBinPath) pandocVer := getPandocVer(PandocBinPath)
if "" != pandocVer { if "" != pandocVer {
@ -143,6 +157,13 @@ func InitPandoc() {
pandocZip = filepath.Join(WorkingDir, "pandoc/pandoc-linux-amd64.zip") pandocZip = filepath.Join(WorkingDir, "pandoc/pandoc-linux-amd64.zip")
} }
} }
if !gulu.File.IsExist(pandocZip) {
PandocBinPath = ""
logging.LogErrorf("pandoc zip [%s] not found", pandocZip)
return
}
if err := gulu.Zip.Unzip(pandocZip, pandocDir); nil != err { if err := gulu.Zip.Unzip(pandocZip, pandocDir); nil != err {
logging.LogErrorf("unzip pandoc failed: %s", err) logging.LogErrorf("unzip pandoc failed: %s", err)
return return