Skip to content

Commit adcbfcd

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

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-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

+14-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ func checkForUpdates(currentVersion string, updateURL string, cmdName string) (s
7070
}
7171

7272
// Fetch information about updates
73-
info, err := fetchInfo(updateURL, cmdName)
73+
74+
// updateURL: "https://downloads.arduino.cc/"
75+
// cmdName: "CreateAgent/Stable"
76+
// plat: "darwin-amd64"
77+
// info URL: "https://downloads.arduino.cc/CreateAgent/Stable/darwin-amd64-bundle.json"
78+
infoURL := updateURL + cmdName + "/" + plat + "-bundle.json"
79+
info, err := fetchInfo(infoURL)
7480
if err != nil {
7581
return "", err
7682
}
@@ -88,7 +94,13 @@ func checkForUpdates(currentVersion string, updateURL string, cmdName string) (s
8894
defer tmp.RemoveAll()
8995

9096
// Download the update.
91-
downloadURL := updateURL + cmdName + "/" + info.Version + "/ArduinoCreateAgent.app_notarized.zip"
97+
98+
// updateURL: "https://downloads.arduino.cc/"
99+
// cmdName == "CreateAgent/Stable"
100+
// info.Version == "1.2.8"
101+
// runtime.GOARCH: "amd64"
102+
// downloadURL: "https://downloads.arduino.cc/CreateAgent/Stable/1.2.8/ArduinoCreateAgent.app_arm64_notarized.zip"
103+
downloadURL := updateURL + cmdName + "/" + info.Version + "/ArduinoCreateAgent.app_" + runtime.GOARCH + "_notarized.zip"
92104
logrus.WithField("url", downloadURL).Info("Downloading update")
93105
download, err := fetch(downloadURL)
94106
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)