diff --git a/src/blackcore/db/databasereader.cpp b/src/blackcore/db/databasereader.cpp index 9a386238b..599a32471 100644 --- a/src/blackcore/db/databasereader.cpp +++ b/src/blackcore/db/databasereader.cpp @@ -55,6 +55,7 @@ namespace BlackCore while (currentEntity) { const CDatabaseReaderConfig config(this->getConfigForEntity(currentEntity)); + const QString currentEntityName = CEntityFlags::flagToString(currentEntity); if (config.getRetrievalMode().testFlag(CDbFlags::Cached)) { if (hasInfoObjects) @@ -64,28 +65,23 @@ namespace BlackCore const QDateTime latestEntityTs(this->getLatestEntityTimestamp(currentEntity)); const qint64 cacheTimestamp = cacheTs.isValid() ? cacheTs.toMSecsSinceEpoch() : -1; const qint64 latestEntityTimestamp = latestEntityTs.isValid() ? latestEntityTs.toMSecsSinceEpoch() : -1; - Q_ASSERT_X(latestEntityTimestamp > 0, Q_FUNC_INFO, "Missing timestamp"); - if (!changedUrl && cacheTimestamp >= latestEntityTimestamp && cacheTimestamp > 0) + Q_ASSERT_X(latestEntityTimestamp >= 0, Q_FUNC_INFO, "Missing timestamp"); + if (!changedUrl && cacheTimestamp >= latestEntityTimestamp && cacheTimestamp >= 0 && latestEntityTimestamp >= 0) { this->syncronizeCaches(currentEntity); entities &= ~currentEntity; // do not load from web cachedEntities |= currentEntity; // read from cache - CLogMessage(this).info("Using cache for %1 (%2, %3)") - << CEntityFlags::flagToString(currentEntity) - << cacheTs.toString() << cacheTimestamp; + CLogMessage(this).info("Using cache for %1 (%2, %3)") << currentEntityName << cacheTs.toString() << cacheTimestamp; } else { if (changedUrl) { - CLogMessage(this).info("Data location changed, will override cache for %1") - << CEntityFlags::flagToString(currentEntity); + CLogMessage(this).info("Data location changed, will override cache for %1") << currentEntityName; } else { - CLogMessage(this).info("Cache for %1 outdated, latest entity (%2, %3)") - << CEntityFlags::flagToString(currentEntity) - << latestEntityTs.toString() << latestEntityTimestamp; + CLogMessage(this).info("Cache for %1 outdated, latest entity (%2, %3)") << currentEntityName << latestEntityTs.toString() << latestEntityTimestamp; } } } @@ -94,8 +90,7 @@ namespace BlackCore // no info objects, server down this->syncronizeCaches(currentEntity); const int c = this->getCacheCount(currentEntity); - CLogMessage(this).info("No info object for %1, using cache with %2 objects") - << CEntityFlags::flagToString(currentEntity) << c; + CLogMessage(this).info("No info object for %1, using cache with %2 objects") << currentEntityName << c; entities &= ~currentEntity; // do not load from web cachedEntities |= currentEntity; // read from cache } diff --git a/src/blackcore/db/modeldatareader.cpp b/src/blackcore/db/modeldatareader.cpp index dfdf52ca5..93d33cac1 100644 --- a/src/blackcore/db/modeldatareader.cpp +++ b/src/blackcore/db/modeldatareader.cpp @@ -268,7 +268,7 @@ namespace BlackCore liveries = CLiveryList::fromDatabaseJson(res); } - int n = liveries.size(); + const int n = liveries.size(); qint64 latestTimestamp = liveries.latestTimestampMsecsSinceEpoch(); if (n > 0 && latestTimestamp < 0) { @@ -311,7 +311,7 @@ namespace BlackCore distributors = CDistributorList::fromDatabaseJson(res); } - int n = distributors.size(); + const int n = distributors.size(); qint64 latestTimestamp = distributors.latestTimestampMsecsSinceEpoch(); if (n > 0 && latestTimestamp < 0) { @@ -354,7 +354,7 @@ namespace BlackCore } // syncronized update - int n = models.size(); + const int n = models.size(); qint64 latestTimestamp = models.latestTimestampMsecsSinceEpoch(); if (n > 0 && latestTimestamp < 0) { diff --git a/src/blackmisc/db/dbinfo.cpp b/src/blackmisc/db/dbinfo.cpp index 0a128ca8e..d97894af6 100644 --- a/src/blackmisc/db/dbinfo.cpp +++ b/src/blackmisc/db/dbinfo.cpp @@ -39,6 +39,7 @@ namespace BlackMisc if (this->m_tableName.contains("livery", Qt::CaseInsensitive)) { return CEntityFlags::LiveryEntity; } if (this->m_tableName.contains("aircraftmodel", Qt::CaseInsensitive)) { return CEntityFlags::ModelEntity; } if (this->m_tableName.contains("country", Qt::CaseInsensitive)) { return CEntityFlags::CountryEntity; } + if (this->m_tableName.contains("distributor", Qt::CaseInsensitive)) { return CEntityFlags::DistributorEntity; } return CEntityFlags::NoEntity; } diff --git a/src/blackmisc/network/entityflags.cpp b/src/blackmisc/network/entityflags.cpp index 050d8dc93..8639c06af 100644 --- a/src/blackmisc/network/entityflags.cpp +++ b/src/blackmisc/network/entityflags.cpp @@ -113,6 +113,7 @@ namespace BlackMisc if (entities.testFlag(LiveryEntity)) { entities &= ~LiveryEntity; return LiveryEntity; } if (entities.testFlag(CountryEntity)) { entities &= ~CountryEntity; return CountryEntity; } if (entities.testFlag(ModelEntity)) { entities &= ~ModelEntity; return ModelEntity; } + if (entities.testFlag(DistributorEntity)) { entities &= ~DistributorEntity; return DistributorEntity; } return NoEntity; }