Skip to content

Commit a484330

Browse files
committed
Fixed update URL for different update methods
1 parent 342e243 commit a484330

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

updater/updater.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ const (
4444
plat = runtime.GOOS + "-" + runtime.GOARCH
4545
)
4646

47-
func fetchInfo(updateAPIURL string, cmdName string) (*availableUpdateInfo, error) {
48-
r, err := fetch(updateAPIURL + cmdName + "/" + plat + ".json")
47+
func fetchInfo(updateAPIURL string) (*availableUpdateInfo, error) {
48+
r, err := fetch(updateAPIURL)
4949
if err != nil {
5050
return nil, err
5151
}

updater/updater_darwin.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
"fmt"
4646
"io"
4747
"os"
48+
"runtime"
4849

4950
"github.com/arduino/go-paths-helper"
5051
"github.com/codeclysm/extract/v3"
@@ -70,7 +71,13 @@ func checkForUpdates(currentVersion string, updateURL string, cmdName string) (s
7071
}
7172

7273
// Fetch information about updates
73-
info, err := fetchInfo(updateURL, cmdName)
74+
75+
// updateURL: "https://downloads.arduino.cc/"
76+
// cmdName: "CreateAgent/Stable"
77+
// plat: "darwin-amd64"
78+
// info URL: "https://downloads.arduino.cc/CreateAgent/Stable/darwin-amd64-bundle.json"
79+
infoURL := updateURL + cmdName + "/" + plat + "-bundle.json"
80+
info, err := fetchInfo(infoURL)
7481
if err != nil {
7582
return "", err
7683
}
@@ -88,7 +95,13 @@ func checkForUpdates(currentVersion string, updateURL string, cmdName string) (s
8895
defer tmp.RemoveAll()
8996

9097
// Download the update.
91-
downloadURL := updateURL + cmdName + "/" + info.Version + "/ArduinoCreateAgent.app_notarized.zip"
98+
99+
// updateURL: "https://downloads.arduino.cc/"
100+
// cmdName == "CreateAgent/Stable"
101+
// info.Version == "1.2.8"
102+
// runtime.GOARCH: "amd64"
103+
// downloadURL: "https://downloads.arduino.cc/CreateAgent/Stable/1.2.8/ArduinoCreateAgent.app_arm64_notarized.zip"
104+
downloadURL := updateURL + cmdName + "/" + info.Version + "/ArduinoCreateAgent.app_" + runtime.GOARCH + "_notarized.zip"
92105
logrus.WithField("url", downloadURL).Info("Downloading update")
93106
download, err := fetch(downloadURL)
94107
if err != nil {

updater/updater_default.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ func (u *Updater) update() error {
225225
}
226226
defer old.Close()
227227

228-
info, err := fetchInfo(u.UpdateURL, u.CmdName)
228+
infoURL := u.UpdateURL + u.CmdName + "/" + plat + ".json"
229+
info, err := fetchInfo(infoURL)
229230
if err != nil {
230231
log.Println(err)
231232
return err

0 commit comments

Comments
 (0)