From 1c2ca5fca15b962693fb8ce8e24f370e4065bab2 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 13 Apr 2017 01:17:23 +0200 Subject: [PATCH] refs #935, avoid timestamp "overflow" --- src/blackcore/db/databasereader.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/blackcore/db/databasereader.cpp b/src/blackcore/db/databasereader.cpp index f579ca5ad..8ecf22928 100644 --- a/src/blackcore/db/databasereader.cpp +++ b/src/blackcore/db/databasereader.cpp @@ -353,9 +353,17 @@ namespace BlackCore const QDateTime cacheTs(this->getCacheTimestamp(entity)); if (!cacheTs.isValid()) { return true; } // we have no cache ts - const QDateTime hts(this->getLatestSharedFileHeaderTimestamp(entity)); - if (!hts.isValid()) { return false; } - return hts > cacheTs; + const QDateTime headerTimestamp(this->getLatestSharedFileHeaderTimestamp(entity)); + if (!headerTimestamp.isValid()) { return false; } + + // we restrict by latest entity from info objects (if available) + // a header ts shall be never newer than the info object, if it is it is an issue with shared file sync + const QDateTime infoObjectTs = this->getLatestEntityTimestampFromInfoObjects(entity); + if (infoObjectTs.isValid() && infoObjectTs < headerTimestamp) + { + return infoObjectTs > cacheTs; + } + return headerTimestamp > cacheTs; } CEntityFlags::Entity CDatabaseReader::getEntitesWithNewerHeaderTimestamp(CEntityFlags::Entity entities) const