Skip to content

Commit

Permalink
fix: change download function
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lyledouglass committed Jan 1, 2024
1 parent 5f304b3 commit 6271d88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions internal/appUpdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"io"
"net/http"
"os"
"os/user"
"path/filepath"
"regexp"
"strings"
"time"
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
Expand Down Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func main() {

const version = "5.0.0"
const version = "5.0.1"

var (
logging string
Expand Down

0 comments on commit 6271d88

Please sign in to comment.