MCPcopy Create free account
hub / github.com/VCVRack/Rack / checkAppUpdate

Function checkAppUpdate

src/library.cpp:67–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67void checkAppUpdate() {
68 if (!appUpdateMutex.try_lock())
69 return;
70 DEFER({appUpdateMutex.unlock();});
71
72 std::string versionUrl = API_URL + "/version";
73 json_t* reqJ = json_object();
74 json_object_set_new(reqJ, "edition", json_string(APP_EDITION.c_str()));
75 DEFER({json_decref(reqJ);});
76
77 json_t* resJ = network::requestJson(network::METHOD_GET, versionUrl, reqJ);
78 if (!resJ) {
79 WARN("Request for version failed");
80 return;
81 }
82 DEFER({json_decref(resJ);});
83
84 json_t* versionJ = json_object_get(resJ, "version");
85 if (versionJ) {
86 std::string appVersion = json_string_value(versionJ);
87 // Check if app version is more recent than current version
88 if (string::Version(APP_VERSION) < string::Version(appVersion))
89 library::appVersion = appVersion;
90 }
91
92 json_t* changelogUrlJ = json_object_get(resJ, "changelogUrl");
93 if (changelogUrlJ)
94 appChangelogUrl = json_string_value(changelogUrlJ);
95
96 json_t* downloadUrlsJ = json_object_get(resJ, "downloadUrls");
97 if (downloadUrlsJ) {
98 std::string arch = APP_OS + "-" + APP_CPU;
99 json_t* downloadUrlJ = json_object_get(downloadUrlsJ, arch.c_str());
100 if (downloadUrlJ)
101 appDownloadUrl = json_string_value(downloadUrlJ);
102 }
103}
104
105
106bool isAppUpdateAvailable() {

Callers 2

initFunction · 0.85
onActionMethod · 0.85

Calls 4

requestJsonFunction · 0.85
VersionClass · 0.85
try_lockMethod · 0.80
unlockMethod · 0.80

Tested by

no test coverage detected