Skip to content

Commit e336328

Browse files
committed
Query only the latest release when the pre-release setting is disabled
Avoid downloading and looking through the entire list of releases when all we need is the latest release.
1 parent b541d39 commit e336328

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

scripts/check_updates/check_updates.gml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ function check_updates() {
3535
var res = async_load[? "result"];
3636
res = json_parse(res);
3737

38-
// Iterate array of releases and get the first (latest) release OR pre-release
39-
var release = -1;
40-
for (var i = 0; i < array_length(res); i++) {
41-
if (check_prerelease || !res[i].prerelease) {
42-
release = res[i];
43-
break;
38+
if (check_prerelease) {
39+
// Iterate array of releases and get the first (latest) release OR pre-release
40+
var release = -1;
41+
for (var i = 0; i < array_length(res); i++) {
42+
if (check_prerelease || !res[i].prerelease) {
43+
release = res[i];
44+
break;
45+
}
4446
}
47+
} else {
48+
release = res;
4549
}
4650

4751
if (release != -1) {

scripts/control_create/control_create.gml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,11 @@ function control_create() {
488488

489489
// Updates
490490
if (check_update)
491-
update_http = http_get(link_releases)
491+
if (check_prerelease) {
492+
update_http = http_get(link_releases)
493+
} else {
494+
update_http = http_get(link_latest)
495+
}
492496
else
493497
update_http = -1
494498
update_download = -1

scripts/macros/macros.gml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function macros() {
99
#macro link_github "https://github.com/OpenNBS/OpenNoteBlockStudio"
1010
#macro link_report "https://github.com/OpenNBS/OpenNoteBlockStudio/issues/new/choose"
1111
#macro link_releases "https://api.github.com/repos/OpenNBS/OpenNoteBlockStudio/releases"
12+
#macro link_latest "https://api.github.com/repos/OpenNBS/OpenNoteBlockStudio/releases/latest"
1213
#macro link_changelog "https://opennbs.org/changelog"
1314
#macro link_website "https://opennbs.org/"
1415
#macro link_discord "https://discord.gg/sKPGjyVcyy"

0 commit comments

Comments
 (0)