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.
This commit is contained in:
Klaus Basan
2018-12-04 02:53:05 +01:00
parent 40afedcaed
commit 3c20590293
5 changed files with 32 additions and 12 deletions

View File

@@ -417,10 +417,21 @@ namespace BlackCore
}); });
// setup handling completed with success or failure, or we run into time out // 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 // 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()) if (m_setupReader->getLastSetupReadErrorMessages().hasErrorMessages())
{ {
msgs.push_back(m_setupReader->getLastSetupReadErrorMessages()); msgs.push_back(m_setupReader->getLastSetupReadErrorMessages());

View File

@@ -308,7 +308,7 @@ namespace BlackCore
mutable QReadWriteLock m_statusLock; //!< Lock mutable QReadWriteLock m_statusLock; //!< Lock
QNetworkReply::NetworkError m_1stReplyStatus = QNetworkReply::UnknownServerError; //!< Successful connection? QNetworkReply::NetworkError m_1stReplyStatus = QNetworkReply::UnknownServerError; //!< Successful connection?
QMap<BlackMisc::Network::CEntityFlags::Entity, HeaderResponse> m_sharedFileResponses; //!< file responses of the shared files QMap<BlackMisc::Network::CEntityFlags::Entity, HeaderResponse> 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 //! Constructor
CDatabaseReader(QObject *owner, const CDatabaseReaderConfigList &config, const QString &name); CDatabaseReader(QObject *owner, const CDatabaseReaderConfigList &config, const QString &name);

View File

@@ -202,6 +202,11 @@ namespace BlackCore
m_shutdown = true; m_shutdown = true;
} }
void CSetupReader::forceAvailabilityUpdate()
{
this->manageSetupAvailability(false, false); // fake a failed web read
}
void CSetupReader::readSetup() void CSetupReader::readSetup()
{ {
const CStatusMessageList msgs(this->triggerReadSetup()); const CStatusMessageList msgs(this->triggerReadSetup());

View File

@@ -149,6 +149,10 @@ namespace BlackCore
//! \threadsafe //! \threadsafe
bool isSetupAvailable() const { return m_setupAvailable; } 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? //! Version info available?
//! \threadsafe //! \threadsafe
bool isUpdateInfoAvailable() const { return m_updateInfoAvailable; } bool isUpdateInfoAvailable() const { return m_updateInfoAvailable; }