From 3c20590293df8c98d2f8cab9449285b71df5c292 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 4 Dec 2018 02:53:05 +0100 Subject: [PATCH] Allow a forced update of the setup reader When the network is down it can happen the bootstrap file request is not yet timed out but we use our own time out. In that case we check the cached data upfront by faking a failed web read. --- src/blackcore/application.cpp | 15 +++++++++++++-- src/blackcore/application.h | 18 +++++++++--------- src/blackcore/db/databasereader.h | 2 +- src/blackcore/setupreader.cpp | 5 +++++ src/blackcore/setupreader.h | 4 ++++ 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index a69313302..220a4d0f6 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -417,10 +417,21 @@ namespace BlackCore }); // setup handling completed with success or failure, or we run into time out - if (m_setupReader->isSetupAvailable()) { return CStatusMessage(this).info("Setup available"); } + CStatusMessageList msgs; + bool forced = false; + if (!m_setupReader->isSetupAvailable()) + { + forced = true; + m_setupReader->forceAvailabilityUpdate(); // maybe web reading still hanging + } + if (m_setupReader->isSetupAvailable()) + { + msgs.push_back(CStatusMessage(this).info(forced ? "Setup available after forcing (so likely web read still pending)" : "Setup available")); + return msgs; + } // getting here can means no "real" read success, and NO available cache - CStatusMessageList msgs(CStatusMessage(this).error("Setup not available, setup reading failed or timed out.")); + msgs.push_back(CStatusMessage(this).error("Setup not available, setup reading failed or timed out.")); if (m_setupReader->getLastSetupReadErrorMessages().hasErrorMessages()) { msgs.push_back(m_setupReader->getLastSetupReadErrorMessages()); diff --git a/src/blackcore/application.h b/src/blackcore/application.h index 35802fd84..9e073cf5e 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -654,10 +654,10 @@ namespace BlackCore //! Write meta information into the application directory so other swift versions can display them void tagApplicationDataDirectory(); - CInputManager *m_inputManager = nullptr; //!< Input devices and hotkeys - QNetworkConfigurationManager *m_networkConfigManager = nullptr; //!< configuration - QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager - Db::CNetworkWatchdog *m_networkWatchDog = nullptr; //!< checking DB/internet access + CInputManager *m_inputManager = nullptr; //!< Input devices and hotkeys + QNetworkConfigurationManager *m_networkConfigManager = nullptr; //!< configuration + QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager + Db::CNetworkWatchdog *m_networkWatchDog = nullptr; //!< checking DB/internet access BlackMisc::CApplicationInfo m_applicationInfo; //!< Application if specified QScopedPointer m_coreFacade; //!< core facade if any QScopedPointer m_setupReader; //!< setup reader @@ -670,12 +670,12 @@ namespace BlackCore CWebReaderFlags::WebReader m_webReadersUsed; //!< Readers to be used Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< Load or used caching? bool m_noNwAccessPoint = false; //!< no network access point? - bool m_useContexts = false; //!< use contexts - bool m_useWebData = false; //!< use web data - bool m_signalStartup = true; //!< signal startup automatically - bool m_devFlag = false; //!< dev. environment + bool m_useContexts = false; //!< use contexts + bool m_useWebData = false; //!< use web data + bool m_signalStartup = true; //!< signal startup automatically + bool m_devFlag = false; //!< dev. environment bool m_saveSettingsOnShutdown = true; //!< saving all settings on shutdown - bool m_localSettingsLoaded = false; //!< local settings loaded? + bool m_localSettingsLoaded = false; //!< local settings loaded? // -------------- crashpad ----------------- //! Init the crash handler diff --git a/src/blackcore/db/databasereader.h b/src/blackcore/db/databasereader.h index e9ff667e0..a5f56e797 100644 --- a/src/blackcore/db/databasereader.h +++ b/src/blackcore/db/databasereader.h @@ -308,7 +308,7 @@ namespace BlackCore mutable QReadWriteLock m_statusLock; //!< Lock QNetworkReply::NetworkError m_1stReplyStatus = QNetworkReply::UnknownServerError; //!< Successful connection? QMap m_sharedFileResponses; //!< file responses of the shared files - BlackMisc::CStatusMessage::StatusSeverity m_severityNoWorkingUrl = BlackMisc::CStatusMessage::SeverityError; //!< severity of message if there is no working URL + BlackMisc::CStatusMessage::StatusSeverity m_severityNoWorkingUrl = BlackMisc::CStatusMessage::SeverityWarning; //!< severity of message if there is no working URL //! Constructor CDatabaseReader(QObject *owner, const CDatabaseReaderConfigList &config, const QString &name); diff --git a/src/blackcore/setupreader.cpp b/src/blackcore/setupreader.cpp index 7ddc3c5e6..da6a15e5e 100644 --- a/src/blackcore/setupreader.cpp +++ b/src/blackcore/setupreader.cpp @@ -202,6 +202,11 @@ namespace BlackCore m_shutdown = true; } + void CSetupReader::forceAvailabilityUpdate() + { + this->manageSetupAvailability(false, false); // fake a failed web read + } + void CSetupReader::readSetup() { const CStatusMessageList msgs(this->triggerReadSetup()); diff --git a/src/blackcore/setupreader.h b/src/blackcore/setupreader.h index 51493434e..0d9f58b6e 100644 --- a/src/blackcore/setupreader.h +++ b/src/blackcore/setupreader.h @@ -149,6 +149,10 @@ namespace BlackCore //! \threadsafe bool isSetupAvailable() const { return m_setupAvailable; } + //! Force an availability update + //! \remark check for cached setup if the read check never got triggered + void forceAvailabilityUpdate(); + //! Version info available? //! \threadsafe bool isUpdateInfoAvailable() const { return m_updateInfoAvailable; }