datadragon: more logging, do not refresh cache when it was read

This commit is contained in:
mrbesen 2022-07-17 01:22:31 +02:00
parent bb4555585e
commit 97a822746e
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 12 additions and 3 deletions

View File

@ -281,7 +281,8 @@ void DataDragon::getChampsInternal() {
}
QJsonDocument jchamps = champCache.getChamps();
if(jchamps.isEmpty()) {
bool cacheSuccessfull = !jchamps.isEmpty();
if(!cacheSuccessfull) {
jchamps = request(getCDNString() + "data/" + locale + "/champion.json");
if(jchamps.isEmpty()) {
// try again with default locale
@ -291,7 +292,9 @@ void DataDragon::getChampsInternal() {
}
if(jchamps.isObject()) {
// save to cache
champCache.saveChamps(jchamps, version);
if(!cacheSuccessfull) {
champCache.saveChamps(jchamps, version);
}
QJsonObject obj = jchamps.object();
auto it = obj.constFind("data");
@ -305,7 +308,7 @@ void DataDragon::getChampsInternal() {
}
}
}
Log::info << "loaded " << champs.size() << " champs";
Log::info << "loaded " << champs.size() << " champs from cache: " << cacheSuccessfull;
lock.unlock();
cachedatacv.notify_all();
}
@ -357,6 +360,12 @@ void DataDragon::threadLoop() {
if(notDownloadedImages.empty() && tasks.empty()) {
// everything prefetched, but nothing more to do
static bool once = false;
if(!once) {
once = true;
Log::note << "all champs are prefetched now";
}
tasksnotemptycv.wait(lock);
}
}