mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Fix some issues with GalaxyConfig
Fix compile error: "conversion from ‘time_t {aka long int}’ to ‘const Json::Value’ is ambiguous" Add checks for missing "expires_in" value in Galaxy tokens json
This commit is contained in:
parent
2b9c7f9273
commit
d6d3d3a40e
@ -64,8 +64,9 @@ class GalaxyConfig
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m);
|
std::unique_lock<std::mutex> lock(m);
|
||||||
bool bExpired = false;
|
bool bExpired = false;
|
||||||
|
intmax_t time_now = time(NULL);
|
||||||
if (this->token_json.isMember("expires_at"))
|
if (this->token_json.isMember("expires_at"))
|
||||||
bExpired = (time(NULL) > this->token_json["expires_at"].asUInt());
|
bExpired = (time_now > this->token_json["expires_at"].asLargestInt());
|
||||||
return bExpired;
|
return bExpired;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +92,16 @@ class GalaxyConfig
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m);
|
std::unique_lock<std::mutex> lock(m);
|
||||||
if (!json.isMember("expires_at"))
|
if (!json.isMember("expires_at"))
|
||||||
json["expires_at"] = json["expires_in"].asUInt() + time(NULL);
|
{
|
||||||
|
intmax_t time_now = time(NULL);
|
||||||
|
Json::Value::LargestInt expires_in = 3600;
|
||||||
|
if (json.isMember("expires_in"))
|
||||||
|
if (!json["expires_in"].isNull())
|
||||||
|
expires_in = json["expires_in"].asLargestInt();
|
||||||
|
|
||||||
|
Json::Value::LargestInt expires_at = time_now + expires_in;
|
||||||
|
json["expires_at"] = expires_at;
|
||||||
|
}
|
||||||
this->token_json = json;
|
this->token_json = json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,8 @@ Downloader::Downloader()
|
|||||||
if (!json.isMember("expires_at"))
|
if (!json.isMember("expires_at"))
|
||||||
{
|
{
|
||||||
std::time_t last_modified = boost::filesystem::last_write_time(Globals::galaxyConf.getFilepath());
|
std::time_t last_modified = boost::filesystem::last_write_time(Globals::galaxyConf.getFilepath());
|
||||||
json["expires_at"] = json["expires_in"].asUInt() + last_modified;
|
Json::Value::LargestInt expires_in = json["expires_in"].asLargestInt();
|
||||||
|
json["expires_at"] = expires_in + last_modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
Globals::galaxyConf.setJSON(json);
|
Globals::galaxyConf.setJSON(json);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user