mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-26 18:26:09 +01:00
🎨 Remove the target docx file when exporting Fix https://github.com/siyuan-note/siyuan/issues/8822
This commit is contained in:
parent
5822d1f7af
commit
bc36dc142a
6 changed files with 21 additions and 6 deletions
|
|
@ -377,7 +377,17 @@ func ExportDocx(id, savePath string, removeAssets, merge bool) (err error) {
|
|||
return errors.New(msg)
|
||||
}
|
||||
|
||||
if err = filelock.Copy(tmpDocxPath, filepath.Join(savePath, name+".docx")); nil != err {
|
||||
targetPath := filepath.Join(savePath, name+".docx")
|
||||
if gulu.File.IsExist(targetPath) {
|
||||
// 先删除目标文件,以检查是否被占用 https://github.com/siyuan-note/siyuan/issues/8822
|
||||
if err := os.RemoveAll(targetPath); nil != err {
|
||||
logging.LogErrorf("export docx failed: %s", err)
|
||||
msg := fmt.Sprintf(Conf.language(215))
|
||||
return errors.New(msg)
|
||||
}
|
||||
}
|
||||
|
||||
if err = filelock.Copy(tmpDocxPath, targetPath); nil != err {
|
||||
logging.LogErrorf("export docx failed: %s", err)
|
||||
return errors.New(fmt.Sprintf(Conf.Language(14), err))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue