mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 13:35:34 +08:00
Ref T367, do not read again when info/setup was just read (age)
This commit is contained in:
@@ -221,6 +221,14 @@ namespace BlackCore
|
||||
return msgs;
|
||||
}
|
||||
|
||||
if (m_setup.lastUpdatedAge() < 5000)
|
||||
{
|
||||
const CStatusMessage m(this, CStatusMessage::SeverityInfo, "Update info just updated, skip read");
|
||||
CStatusMessageList msgs(m);
|
||||
this->setLastSetupReadErrorMessages(msgs);
|
||||
return msgs;
|
||||
}
|
||||
|
||||
// trigger two reads, the file size is small
|
||||
const CUrlList randomUrls = m_bootstrapUrls.randomElements(2);
|
||||
CUrl url = randomUrls.front();
|
||||
@@ -252,11 +260,17 @@ namespace BlackCore
|
||||
const CUrlList randomUrls = m_updateInfoUrls.randomElements(2);
|
||||
if (randomUrls.isEmpty())
|
||||
{
|
||||
CStatusMessage(this).warning("Cannot read update info, no URLs");
|
||||
CLogMessage(this).warning("Cannot read update info, no URLs");
|
||||
this->manageUpdateInfoAvailability(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_updateInfo.lastUpdatedAge() < 5000)
|
||||
{
|
||||
CLogMessage(this).info("Update info just updated, skip read");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sApp || m_shutdown) { return; }
|
||||
CUrl url = randomUrls.front();
|
||||
const CStatusMessage m1(this, CStatusMessage::SeverityInfo, "Start reading update info 1st URL: " + url.toQString());
|
||||
|
||||
@@ -418,6 +418,13 @@ namespace BlackMisc
|
||||
//! \threadsafe with tiny risk of mismatch of value and timestamp
|
||||
QDateTime getTimestamp() const { return QDateTime::fromMSecsSinceEpoch(m_page->getTimestamp(*m_element)); }
|
||||
|
||||
//! Return the time when this value was updated.
|
||||
//! \threadsafe with tiny risk of mismatch of value and timestamp
|
||||
qint64 getTimestampMsSinceEpoch() const { return this->getTimestamp().toMSecsSinceEpoch(); }
|
||||
|
||||
//! How old is that cache (ms)?
|
||||
qint64 lastUpdatedAge() const { return QDateTime::currentMSecsSinceEpoch() - this->getTimestampMsSinceEpoch(); }
|
||||
|
||||
//! Return true if this value was already saved.
|
||||
bool isSaved() const { return m_page->isSaved(*m_element); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user