From 0c466dc8878b111b956731073b2b03313f96ac29 Mon Sep 17 00:00:00 2001 From: Kalin Staykov Date: Sun, 13 Nov 2022 18:49:40 +0200 Subject: [PATCH] do not overwrite docx file if it exist --- pkg/converter/converter.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/converter/converter.go b/pkg/converter/converter.go index 1093163..cfe42a2 100644 --- a/pkg/converter/converter.go +++ b/pkg/converter/converter.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "log" + "os" "path/filepath" "regexp" "strings" @@ -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: