Skip to content

Commit 1f2c3d4

Browse files
committed
Update: Get nightly (prerelease) builds from Github
We are now deploying official builds from master to Github releases page (as Prerelease). So we should get these build from there. This is also related to AppVeyor's rather tight download limits that make it quite challenge to obtain nightly builds.
1 parent 5bee5ae commit 1f2c3d4

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

Src/Lib/DownloadHelper.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static DWORD WINAPI ThreadVersionCheck( void *param )
344344
VersionData data;
345345

346346
{
347-
auto load = params.nightly ? data.LoadNightly() : data.Load();
347+
auto load = data.Load(!params.nightly);
348348

349349
#ifdef UPDATE_LOG
350350
LogToFile(UPDATE_LOG, L"Load result: %d", load);
@@ -765,20 +765,38 @@ std::vector<char> DownloadUrl(const wchar_t* url)
765765

766766
using namespace nlohmann;
767767

768-
VersionData::TLoadResult VersionData::Load()
768+
VersionData::TLoadResult VersionData::Load(bool official)
769769
{
770770
Clear();
771771

772-
auto buf = DownloadUrl(L"https://api.github.com/repos/Open-Shell/Open-Shell-Menu/releases/latest");
772+
std::wstring baseUrl = L"https://api.github.com/repos/Open-Shell/Open-Shell-Menu/releases";
773+
if (official)
774+
baseUrl += L"/latest";
775+
776+
auto buf = DownloadUrl(baseUrl.c_str());
773777
if (buf.empty())
774778
return LOAD_ERROR;
775779

776780
try
777781
{
778-
auto data = json::parse(buf.begin(), buf.end());
782+
auto jsonData = json::parse(buf.begin(), buf.end());
783+
auto& data = jsonData;
784+
785+
if (official)
786+
{
787+
// skip prerelease versions (just in case)
788+
if (data["prerelease"].get<bool>())
789+
return LOAD_BAD_VERSION;
790+
}
791+
else
792+
{
793+
// we've got list of versions (release and pre-release)
794+
// lets pick first one (that should be the latest one)
795+
data = jsonData[0];
796+
}
779797

780-
// skip prerelease versions
781-
if (data["prerelease"].get<bool>())
798+
// make sure we didn't get draft release (for whatever reason)
799+
if (data["draft"].get<bool>())
782800
return LOAD_BAD_VERSION;
783801

784802
// get version from tag name

Src/Lib/DownloadHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct VersionData
5959
LOAD_BAD_FILE, // the file is corrupted
6060
};
6161

62-
TLoadResult Load();
62+
TLoadResult Load(bool official);
6363
TLoadResult LoadNightly();
6464
TLoadResult Load( const wchar_t *fname, bool bLoadFlags );
6565
private:

0 commit comments

Comments
 (0)