🎨 导出 PDF 和 Word 时支持覆盖已有文件 https://github.com/siyuan-note/siyuan/issues/5309

This commit is contained in:
Liang Ding 2022-07-20 10:43:02 +08:00
parent 42eb0e6ad9
commit 958ddf147c
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 5 additions and 4 deletions

View file

@ -135,7 +135,8 @@ func exportDocx(c *gin.Context) {
id := arg["id"].(string)
savePath := arg["savePath"].(string)
err := model.ExportDocx(id, savePath)
removeAssets := arg["removeAssets"].(bool)
err := model.ExportDocx(id, savePath, removeAssets)
if nil != err {
ret.Code = 1
ret.Msg = err.Error()

View file

@ -155,7 +155,7 @@ func Preview(id string) string {
return luteEngine.ProtylePreview(tree, luteEngine.RenderOptions)
}
func ExportDocx(id, savePath string) (err error) {
func ExportDocx(id, savePath string, removeAssets bool) (err error) {
if !util.IsValidPandocBin(Conf.Export.PandocBin) {
return errors.New(Conf.Language(115))
}
@ -184,8 +184,8 @@ func ExportDocx(id, savePath string) (err error) {
logging.LogErrorf("export docx failed: %s", err)
return errors.New(fmt.Sprintf(Conf.Language(14), err))
}
tmpAssets := filepath.Join(tmpDir, "assets")
if gulu.File.IsDir(tmpAssets) {
if tmpAssets := filepath.Join(tmpDir, "assets"); !removeAssets && gulu.File.IsDir(tmpAssets) {
if err = gulu.File.Copy(tmpAssets, filepath.Join(savePath, "assets")); nil != err {
logging.LogErrorf("export docx failed: %s", err)
return errors.New(fmt.Sprintf(Conf.Language(14), err))