From 8ebf955dda6417ff12ba8ac007b584eb39c73ff3 Mon Sep 17 00:00:00 2001 From: Sergey Voloshin Date: Sun, 12 Dec 2021 22:34:20 +0300 Subject: [PATCH] fix(app): deleting temporary files before updating --- command/self_update.go | 9 +++++++++ main.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/command/self_update.go b/command/self_update.go index 485f28e..38f217f 100644 --- a/command/self_update.go +++ b/command/self_update.go @@ -142,6 +142,15 @@ func extractArchive(archivePath string) error { tarReader := tar.NewReader(uncompressedStream) tmpPath := filepath.Join(os.TempDir(), "dl") + + _, err = os.Stat(tmpPath) + if err == nil { + err = os.RemoveAll(tmpPath) + if err != nil { + return err + } + } + if err := os.Mkdir(tmpPath, 0755); err != nil { return err } diff --git a/main.go b/main.go index a4fc338..8db5221 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ import ( "github.com/varrcan/dl/helper" ) -var version = "0.2.1" +var version = "0.2.2" func main() { if !helper.IsConfigDirExists() {