mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
解决导出文档失败的BUG
This commit is contained in:
@@ -223,7 +223,7 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
|
||||
docxpath := filepath.Join(outputPath, "book.docx")
|
||||
|
||||
//先将转换的文件储存到临时目录
|
||||
tempOutputPath := filepath.Join(os.TempDir(), sessionId, m.Identify) //filepath.Abs(filepath.Join("cache", sessionId))
|
||||
tempOutputPath := filepath.Join(os.TempDir(), sessionId, m.Identify,"source") //filepath.Abs(filepath.Join("cache", sessionId))
|
||||
|
||||
os.MkdirAll(outputPath, 0766)
|
||||
os.MkdirAll(tempOutputPath, 0766)
|
||||
@@ -366,21 +366,23 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
|
||||
|
||||
eBookConverter := &converter.Converter{
|
||||
BasePath: tempOutputPath,
|
||||
OutputPath: strings.TrimSuffix(tempOutputPath, "sources"),
|
||||
OutputPath: filepath.Join(strings.TrimSuffix(tempOutputPath, "source"),"output"),
|
||||
Config: ebookConfig,
|
||||
Debug: true,
|
||||
}
|
||||
|
||||
os.MkdirAll(eBookConverter.OutputPath,0766)
|
||||
|
||||
if err := eBookConverter.Convert(); err != nil {
|
||||
beego.Error("转换文件错误:" + m.BookName + " => " + err.Error())
|
||||
return convertBookResult, err
|
||||
}
|
||||
beego.Info("文档转换完成:" + m.BookName)
|
||||
|
||||
filetil.CopyFile(mobipath, filepath.Join(tempOutputPath, "output", "book.mobi"))
|
||||
filetil.CopyFile(pdfpath, filepath.Join(tempOutputPath, "output", "book.pdf"))
|
||||
filetil.CopyFile(epubpath, filepath.Join(tempOutputPath, "output", "book.epub"))
|
||||
filetil.CopyFile(docxpath, filepath.Join(tempOutputPath, "output", "book.docx"))
|
||||
filetil.CopyFile(filepath.Join(eBookConverter.OutputPath,"output", "book.mobi"),mobipath,)
|
||||
filetil.CopyFile(filepath.Join(eBookConverter.OutputPath,"output", "book.pdf"),pdfpath)
|
||||
filetil.CopyFile(filepath.Join(eBookConverter.OutputPath,"output", "book.epub"),epubpath)
|
||||
filetil.CopyFile(filepath.Join(eBookConverter.OutputPath,"output", "book.docx"),docxpath)
|
||||
|
||||
convertBookResult.MobiPath = mobipath
|
||||
convertBookResult.PDFPath = pdfpath
|
||||
|
||||
@@ -87,6 +87,14 @@ func (m *Document) InsertOrUpdate(cols ...string) error {
|
||||
if m.DocumentId > 0 {
|
||||
_, err = o.Update(m, cols...)
|
||||
} else {
|
||||
if m.Identify == "" {
|
||||
book := NewBook()
|
||||
identify := "docs"
|
||||
if err := o.QueryTable(book.TableNameWithPrefix()).One(book,"identify");err == nil {
|
||||
identify = book.Identify
|
||||
}
|
||||
m.Identify = fmt.Sprintf("%s-%d%d",identify,m.BookId,time.Now().Unix())
|
||||
}
|
||||
_, err = o.Insert(m)
|
||||
NewBook().ResetDocumentNumber(m.BookId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user