mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 00:31:19 +08:00
🐛 Pandoc is not initialized in some cases Fix https://github.com/siyuan-note/siyuan/issues/8533
This commit is contained in:
parent
e93c62e49f
commit
a515a4f992
@ -347,7 +347,7 @@ func exportDocx(c *gin.Context) {
|
||||
}
|
||||
err := model.ExportDocx(id, savePath, removeAssets, merge)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||
return
|
||||
|
@ -19,7 +19,6 @@ package model
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@ -35,6 +34,8 @@ import (
|
||||
"github.com/Xuanwo/go-locale"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
"github.com/siyuan-note/eventbus"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||
@ -892,3 +893,15 @@ func upgradeUserGuide() {
|
||||
index(boxID)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
subscribeConfEvents()
|
||||
}
|
||||
|
||||
func subscribeConfEvents() {
|
||||
eventbus.Subscribe(util.EvtConfPandocInitialized, func() {
|
||||
logging.LogInfof("pandoc initialized, set pandoc bin to [%s]", util.PandocBinPath)
|
||||
Conf.Export.PandocBin = util.PandocBinPath
|
||||
Conf.Save()
|
||||
})
|
||||
}
|
||||
|
@ -333,7 +333,11 @@ func Preview(id string) string {
|
||||
|
||||
func ExportDocx(id, savePath string, removeAssets, merge bool) (err error) {
|
||||
if !util.IsValidPandocBin(Conf.Export.PandocBin) {
|
||||
return errors.New(Conf.Language(115))
|
||||
Conf.Export.PandocBin = util.PandocBinPath
|
||||
Conf.Save()
|
||||
if !util.IsValidPandocBin(Conf.Export.PandocBin) {
|
||||
return errors.New(Conf.Language(115))
|
||||
}
|
||||
}
|
||||
|
||||
tmpDir := filepath.Join(util.TempDir, "export", gulu.Rand.String(7))
|
||||
|
@ -253,6 +253,10 @@ func updateEmbedBlockContent(embedBlockID string, queryResultBlocks []*EmbedBloc
|
||||
}
|
||||
|
||||
func init() {
|
||||
subscribeSQLEvents()
|
||||
}
|
||||
|
||||
func subscribeSQLEvents() {
|
||||
//eventbus.Subscribe(eventbus.EvtSQLInsertBlocks, func(context map[string]interface{}, current, total, blockCount int, hash string) {
|
||||
// if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container {
|
||||
// // Android/iOS 端不显示数据索引和搜索索引状态提示 https://github.com/siyuan-note/siyuan/issues/6392
|
||||
|
@ -57,7 +57,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
subscribeEvents()
|
||||
subscribeRepoEvents()
|
||||
}
|
||||
|
||||
type Snapshot struct {
|
||||
@ -1476,7 +1476,7 @@ func newRepository() (ret *dejavu.Repo, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func subscribeEvents() {
|
||||
func subscribeRepoEvents() {
|
||||
eventbus.Subscribe(eventbus.EvtIndexBeforeWalkData, func(context map[string]interface{}, path string) {
|
||||
msg := fmt.Sprintf(Conf.Language(158), path)
|
||||
util.SetBootDetails(msg)
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/siyuan-note/eventbus"
|
||||
"github.com/siyuan-note/logging"
|
||||
)
|
||||
|
||||
@ -105,6 +106,8 @@ func initPandoc() {
|
||||
}
|
||||
}
|
||||
|
||||
defer eventbus.Publish(EvtConfPandocInitialized)
|
||||
|
||||
if gulu.OS.IsWindows() {
|
||||
PandocBinPath = filepath.Join(pandocDir, "bin", "pandoc.exe")
|
||||
} else if gulu.OS.IsDarwin() || gulu.OS.IsLinux() {
|
||||
|
@ -401,3 +401,7 @@ func existAvailabilityStatus(workspaceAbsPath string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const (
|
||||
EvtConfPandocInitialized = "conf.pandoc.initialized"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user