refs #478, refs #470 setup reader now detects when data version or data type changes

This commit is contained in:
Klaus Basan
2015-10-21 18:52:29 +02:00
committed by Mathew Sutcliffe
parent 4804d81857
commit a9fc21af2f

View File

@@ -145,38 +145,43 @@ namespace BlackCore
} }
else else
{ {
CGlobalSetup gs; QString type(urlString.toLower().contains("develop") ? "DEV" : "PRODUCTIVE");
gs.convertFromJson(Json::jsonObjectFromString(setupJson)); CGlobalSetup currentSetup(m_setup.get());
if (gs.getMSecsSinceEpoch() == 0 && lastModified > 0) { gs.setMSecsSinceEpoch(lastModified); } CGlobalSetup loadedSetup;
qint64 currentVersionTimestamp = m_setup.get().getMSecsSinceEpoch(); loadedSetup.convertFromJson(Json::jsonObjectFromString(setupJson));
qint64 newVersionTimestamp = gs.getMSecsSinceEpoch(); loadedSetup.setType(type);
bool newVersionLoaded = (newVersionTimestamp - currentVersionTimestamp) > 0; if (loadedSetup.getMSecsSinceEpoch() == 0 && lastModified > 0) { loadedSetup.setMSecsSinceEpoch(lastModified); }
bool sameVersionLoaded = newVersionTimestamp == currentVersionTimestamp; bool sameType = loadedSetup.hasSameType(currentSetup.getType());
qint64 currentVersionTimestamp = currentSetup.getMSecsSinceEpoch();
qint64 newVersionTimestamp = loadedSetup.getMSecsSinceEpoch();
bool sameVersionLoaded = sameType && (newVersionTimestamp == currentVersionTimestamp);
if (sameVersionLoaded) if (sameVersionLoaded)
{ {
CLogMessage(this).info("Same version loaded from %1 as already in data cache %2") << urlString << CDataCache::persistentStore(); CLogMessage(this).info("Same version loaded from %1 as already in data cache %2") << urlString << CDataCache::persistentStore();
return; // success return; // success
} }
CStatusMessage m = m_setup.set(gs); bool outdatedVersionLoaded = sameType && (newVersionTimestamp < currentVersionTimestamp);
if (!m.isEmpty()) if (outdatedVersionLoaded)
{ {
CLogMessage(this).preformatted(m); CLogMessage(this).info("Version loaded from %1 outdated, older than version in data cache %2") << urlString << CDataCache::persistentStore();
return; // issue with cache // try next URL
} }
else else
{ {
if (newVersionLoaded) CStatusMessage m = m_setup.set(loadedSetup);
if (!m.isEmpty())
{ {
CLogMessage(this).info("Updated data cache in %1") << CDataCache::persistentStore(); CLogMessage(this).preformatted(m);
return; // success return; // issue with cache
} }
else else
{ {
CLogMessage(this).warning("Local bootstrap file in %1 newer than URL %2") << CDataCache::persistentStore() << urlString; CLogMessage(this).info("Updated data cache in %1") << CDataCache::persistentStore();
// try next URL return; // success
} } // cache
} // cache } // outdated?
} // json empty } // json empty
} // no error } // no error
else else