Skip to content

Commit

Permalink
do not overwrite docx file if it exist
Browse files Browse the repository at this point in the history
  • Loading branch information
kalinstaykov committed Nov 13, 2022
1 parent 8d364c8 commit 0c466dc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
"strings"
Expand Down Expand Up @@ -53,6 +54,10 @@ func Text2Docx(text interface{}, file string) {
para.AddText(t).Size(16).Color("121212")
}
docxFile := strings.Replace(file, "pdf", "docx", 1)
if _, err := os.Stat(docxFile); err == nil {
log.Println("skipping file because it exist - ", docxFile)
return
}
log.Println("writing", docxFile)
f.Save(docxFile)
default:
Expand Down

0 comments on commit 0c466dc

Please sign in to comment.