Fix cache refresh handling for unsaved records

- Preserve NEW_RECORD entries during cache refresh
- Prevent accidental deletion of pending datastore changes
- Clean up only stale persisted records
This commit is contained in:
2026-06-14 17:00:49 +05:30
parent 404d217504
commit f484c62a1e
@@ -230,9 +230,17 @@ void DataStore::refreshCache(util::Map<std::string, TrackedRecord<TObject>>& cac
for (int index = 0; index < oldCache.getSize(); ++index)
{
const std::string& id = oldCache.getKeyAt(index);
const TrackedRecord<TObject>& localTrackedRecord = oldCache.getValueAt(index);
if (cache.find(id) == -1)
{
delete oldCache.getValueAt(index).data;
if (localTrackedRecord.state == RecordState::NEW_RECORD)
{
cache.insert(id, localTrackedRecord);
}
else
{
delete localTrackedRecord.data;
}
}
}
}