mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
refs #715 When loading data cache, prune revision file to remove keys that weren't found.
This commit is contained in:
@@ -293,6 +293,9 @@ namespace BlackMisc
|
||||
auto msg = m_cache->loadFromFiles(persistentStore(), m_cache->m_revision.keysWithNewerTimestamps(), baseline.toVariantMap(), newValues, m_cache->m_revision.timestampsAsString());
|
||||
newValues.setTimestamps(m_cache->m_revision.newerTimestamps());
|
||||
|
||||
auto missingKeys = m_cache->m_revision.keysWithNewerTimestamps().subtract(newValues.keys());
|
||||
if (! missingKeys.isEmpty()) { m_cache->m_revision.writeNewRevision({}, missingKeys); }
|
||||
|
||||
msg.setCategories(this);
|
||||
CLogMessage::preformatted(msg);
|
||||
m_deferredChanges.insert(newValues);
|
||||
@@ -412,7 +415,7 @@ namespace BlackMisc
|
||||
return guard;
|
||||
}
|
||||
|
||||
void CDataCacheRevision::writeNewRevision(const QMap<QString, qint64> &i_timestamps)
|
||||
void CDataCacheRevision::writeNewRevision(const QMap<QString, qint64> &i_timestamps, const QSet<QString> &excludeKeys)
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
|
||||
@@ -433,6 +436,7 @@ namespace BlackMisc
|
||||
{
|
||||
if (it.value()) { timestamps.insert(it.key(), it.value()); }
|
||||
}
|
||||
for (const auto &key : excludeKeys) { timestamps.remove(key); }
|
||||
|
||||
QJsonObject json;
|
||||
json.insert("uuid", m_uuid.toString());
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace BlackMisc
|
||||
LockGuard beginUpdate(const QMap<QString, qint64> ×tamps, bool updateUuid = true, bool pinsOnly = false);
|
||||
|
||||
//! During update, writes a new revision file with new timestamps.
|
||||
void writeNewRevision(const QMap<QString, qint64> ×tamps);
|
||||
void writeNewRevision(const QMap<QString, qint64> ×tamps, const QSet<QString> &excludeKeys = {});
|
||||
|
||||
//! Release the revision file lock and mark everything up-to-date (called by LockGuard destructor).
|
||||
//! \param keepPromises Don't break pending promises.
|
||||
|
||||
Reference in New Issue
Block a user