Merge pull request #583 from diamante0018/fix/changelog
[Changelog]: Re-order urls
This commit is contained in:
commit
47e7b33b54
@ -7,44 +7,44 @@ namespace Components
|
||||
|
||||
void Changelog::LoadChangelog()
|
||||
{
|
||||
//if (!Changelog::Lines.empty())
|
||||
// return;
|
||||
std::lock_guard _(Mutex);
|
||||
Lines.clear();
|
||||
|
||||
std::lock_guard<std::mutex> _(Changelog::Mutex);
|
||||
Changelog::Lines.clear();
|
||||
std::string data = Utils::Cache::GetFile("/develop/CHANGELOG.md");
|
||||
const auto data = Utils::Cache::GetFile("/develop/CHANGELOG.md");
|
||||
|
||||
if (data.empty())
|
||||
{
|
||||
data = "^1Unable to get changelog.";
|
||||
Lines.emplace_back("^1Unable to get changelog.");
|
||||
return;
|
||||
}
|
||||
|
||||
Changelog::Lines = Utils::String::Split(data, '\n');
|
||||
|
||||
for (auto& line : Changelog::Lines)
|
||||
auto buffer = Utils::String::Split(data, '\n');
|
||||
for (auto& line : buffer)
|
||||
{
|
||||
Utils::String::Replace(line, "\r", "");
|
||||
}
|
||||
|
||||
Lines = buffer;
|
||||
}
|
||||
|
||||
unsigned int Changelog::GetChangelogCount()
|
||||
{
|
||||
return Changelog::Lines.size();
|
||||
return Lines.size();
|
||||
}
|
||||
|
||||
// Omit column here
|
||||
const char* Changelog::GetChangelogText(unsigned int item, int /*column*/)
|
||||
const char* Changelog::GetChangelogText(unsigned int item, [[maybe_unused]] int column)
|
||||
{
|
||||
std::lock_guard<std::mutex> _(Changelog::Mutex);
|
||||
if (item < Changelog::Lines.size())
|
||||
std::lock_guard _(Mutex);
|
||||
if (item < Lines.size())
|
||||
{
|
||||
return Utils::String::VA("%s", Changelog::Lines[item].data());
|
||||
return Utils::String::VA("%s", Lines[item].data());
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void Changelog::SelectChangelog(unsigned int /*index*/)
|
||||
void Changelog::SelectChangelog([[maybe_unused]] unsigned int index)
|
||||
{
|
||||
// Don't do anything in here
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ namespace Utils
|
||||
{
|
||||
const char* Cache::Urls[] =
|
||||
{
|
||||
"https://raw.githubusercontent.com/XLabsProject/iw4x-client",
|
||||
"https://xlabs.dev",
|
||||
"https://raw.githubusercontent.com/XLabsProject/iw4x-client"
|
||||
};
|
||||
|
||||
std::string Cache::ValidUrl;
|
||||
@ -13,7 +13,7 @@ namespace Utils
|
||||
|
||||
std::string Cache::GetStaticUrl(const std::string& path)
|
||||
{
|
||||
return Cache::Urls[0] + path;
|
||||
return Urls[0] + path;
|
||||
}
|
||||
|
||||
std::string Cache::GetUrl(const std::string& url, const std::string& path)
|
||||
@ -23,29 +23,27 @@ namespace Utils
|
||||
|
||||
std::string Cache::GetFile(const std::string& path, int timeout, const std::string& useragent)
|
||||
{
|
||||
std::lock_guard<std::mutex> _(Cache::CacheMutex);
|
||||
std::lock_guard _(CacheMutex);
|
||||
|
||||
if (Cache::ValidUrl.empty())
|
||||
if (ValidUrl.empty())
|
||||
{
|
||||
InternetSetCookieA("https://onion.casa", "disclaimer_accepted", "1");
|
||||
InternetSetCookieA("https://hiddenservice.net", "disclaimer_accepted", "1");
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(Cache::Urls); ++i)
|
||||
for (std::size_t i = 0; i < ARRAYSIZE(Urls); ++i)
|
||||
{
|
||||
std::string result = Utils::WebIO(useragent, Cache::GetUrl(Cache::Urls[i], path)).setTimeout(timeout)->get();
|
||||
std::string result = WebIO(useragent, GetUrl(Urls[i], path)).setTimeout(timeout)->get();
|
||||
|
||||
if (!result.empty())
|
||||
{
|
||||
Cache::ValidUrl = Cache::Urls[i];
|
||||
ValidUrl = Urls[i];
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return Utils::WebIO(useragent, Cache::GetUrl(Cache::ValidUrl, path)).setTimeout(timeout)->get();
|
||||
return {};
|
||||
}
|
||||
|
||||
return WebIO(useragent, GetUrl(ValidUrl, path)).setTimeout(timeout)->get();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user