From 6271d88d71318a1b93d8b5a2a617d46852554d3e Mon Sep 17 00:00:00 2001 From: Lyle Douglass Date: Mon, 1 Jan 2024 17:39:05 -0500 Subject: [PATCH] fix: change download function Windows doesn't allow files to be overwritten on the OS if they're in use, unlike Linux, so we need to drop the new exe in the Downloads dir for the current user. There could be a better way of doing this but a simple copy/paste from folder to folder isn't the worst user experience. --- internal/appUpdate.go | 11 +++++++++-- main.go | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/appUpdate.go b/internal/appUpdate.go index a57b3b3..68215ed 100644 --- a/internal/appUpdate.go +++ b/internal/appUpdate.go @@ -7,6 +7,7 @@ import ( "io" "net/http" "os" + "os/user" "path/filepath" "regexp" "strings" @@ -14,7 +15,6 @@ import ( util "wowtools/pkg/utilities" "github.com/google/go-github/v56/github" - "github.com/spf13/viper" ) // Get the latest version of the application from the github api @@ -91,7 +91,14 @@ func UpdateApp(appVersion string) { // can compare the two versions and see if we need to download a new version if latestVersion > appVersion { util.Log.Info("New version available, downloading...") - downloadApp(client, latestVersion, viper.GetString("retail_dir")+"Wowtools") + user, err := user.Current() + if err != nil { + util.Log.Fatalf("Error getting current user: %s", err) + } + homeDir := user.HomeDir + downloadApp(client, latestVersion, homeDir+"Downloads") + util.Log.Info("New version downloaded, please close this application and " + + "move the new version to your desired location to replace this version") } else { util.Log.Info("You are running the latest version") } diff --git a/main.go b/main.go index 84db5b8..cba9bf5 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,7 @@ import ( func main() { - const version = "5.0.0" + const version = "5.0.1" var ( logging string