diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index 9337b6486..0831a8281 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -865,11 +865,18 @@ namespace BlackCore m_webDataServices.reset( new CWebDataServices(m_webReadersUsed, m_dbReaderConfig, {}, this) ); + Q_ASSERT_X(m_webDataServices, Q_FUNC_INFO, "Missing web services"); // caches from local files (i.e. the files delivered) if (this->isInstallerOptionSet()) { - msgs.push_back(m_webDataServices->initDbCachesFromLocalResourceFiles(false)); + const QDateTime ts = m_webDataServices->getLatestDbEntityCacheTimestamp(); + if (!ts.isValid() || ts < QDateTime::currentDateTimeUtc().addYears(-2)) + { + // we only init, if there are: + // a) no cache timestamps b) or it was not updated for some years + msgs.push_back(m_webDataServices->initDbCachesFromLocalResourceFiles(false)); + } } // watchdog diff --git a/src/blackcore/application.h b/src/blackcore/application.h index 77e802eb4..01cf38c83 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -262,7 +262,7 @@ namespace BlackCore //! Delegates to QCommandLineParser::isSet bool isParserOptionSet(const QString &option) const; - //! Installer called? + //! Called by installer? bool isInstallerOptionSet() const; //! Delegates to QCommandLineParser::isSet diff --git a/src/blackcore/webdataservices.cpp b/src/blackcore/webdataservices.cpp index a523b42db..7c3b3e718 100644 --- a/src/blackcore/webdataservices.cpp +++ b/src/blackcore/webdataservices.cpp @@ -419,6 +419,22 @@ namespace BlackCore return reader->getLatestEntityTimestampFromSharedInfoObjects(entity); } + QDateTime CWebDataServices::getLatestDbEntityCacheTimestamp() const + { + QDateTime latest; + const CEntityFlags::EntitySet set = CEntityFlags::asSingleEntities(CEntityFlags::AllDbEntitiesNoInfoObjects); + for (CEntityFlags::Entity e : set) + { + const QDateTime ts = this->getCacheTimestamp(e); + if (!ts.isValid()) { continue; } + if (!latest.isValid() || latest < ts) + { + latest = ts; + } + } + return latest; + } + CEntityFlags::Entity CWebDataServices::getEntitiesWithNewerSharedFile(CEntityFlags::Entity entities) const { Q_ASSERT_X(m_sharedInfoDataReader, Q_FUNC_INFO, "Shared info reader was not initialized"); diff --git a/src/blackcore/webdataservices.h b/src/blackcore/webdataservices.h index d5e0b2cac..bace8b62c 100644 --- a/src/blackcore/webdataservices.h +++ b/src/blackcore/webdataservices.h @@ -77,8 +77,7 @@ namespace BlackCore /*! * Encapsulates reading data from web sources */ - class BLACKCORE_EXPORT CWebDataServices : - public QObject + class BLACKCORE_EXPORT CWebDataServices : public QObject { Q_OBJECT @@ -385,11 +384,17 @@ namespace BlackCore //! \threadsafe QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) const; + //! Latest DB object timestamp, or null if there is no such timestamp + //! \threadsafe + QDateTime getLatestDbEntityCacheTimestamp() const; + //! Corresponding DB timestamp if applicable + //! \remark from Db::CInfoDataReader //! \threadsafe QDateTime getLatestDbEntityTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) const; //! Shared info object timestamp + //! \remark from Db::CInfoDataReader //! \threadsafe QDateTime getLatestSharedInfoObjectTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) const;