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.
This commit is contained in:
ge0rdi
2022-08-21 20:32:43 +02:00
parent 5bee5ae143
commit 1f2c3d43a6
2 changed files with 25 additions and 7 deletions

View File

@@ -344,7 +344,7 @@ static DWORD WINAPI ThreadVersionCheck( void *param )
VersionData data;
{
auto load = params.nightly ? data.LoadNightly() : data.Load();
auto load = data.Load(!params.nightly);
#ifdef UPDATE_LOG
LogToFile(UPDATE_LOG, L"Load result: %d", load);
@@ -765,20 +765,38 @@ std::vector<char> DownloadUrl(const wchar_t* url)
using namespace nlohmann;
VersionData::TLoadResult VersionData::Load()
VersionData::TLoadResult VersionData::Load(bool official)
{
Clear();
auto buf = DownloadUrl(L"https://api.github.com/repos/Open-Shell/Open-Shell-Menu/releases/latest");
std::wstring baseUrl = L"https://api.github.com/repos/Open-Shell/Open-Shell-Menu/releases";
if (official)
baseUrl += L"/latest";
auto buf = DownloadUrl(baseUrl.c_str());
if (buf.empty())
return LOAD_ERROR;
try
{
auto data = json::parse(buf.begin(), buf.end());
auto jsonData = json::parse(buf.begin(), buf.end());
auto& data = jsonData;
// skip prerelease versions
if (data["prerelease"].get<bool>())
if (official)
{
// skip prerelease versions (just in case)
if (data["prerelease"].get<bool>())
return LOAD_BAD_VERSION;
}
else
{
// we've got list of versions (release and pre-release)
// lets pick first one (that should be the latest one)
data = jsonData[0];
}
// make sure we didn't get draft release (for whatever reason)
if (data["draft"].get<bool>())
return LOAD_BAD_VERSION;
// get version from tag name

View File

@@ -59,7 +59,7 @@ struct VersionData
LOAD_BAD_FILE, // the file is corrupted
};
TLoadResult Load();
TLoadResult Load(bool official);
TLoadResult LoadNightly();
TLoadResult Load( const wchar_t *fname, bool bLoadFlags );
private: