Fix cache refresh from overwriting modified records
Changes: - Added a check for RecordState::MODIFIED in DataStore::refreshCache(). - Preserved modified cache records during refresh instead of overwriting them with datastore values. - Discarded refreshed records when a corresponding cached record has pending changes. Fixes #2077
This commit is contained in:
@@ -220,6 +220,12 @@ void DataStore::refreshCache(util::Map<std::string, TrackedRecord<TObject>>& cac
|
|||||||
if (oldIndex != -1)
|
if (oldIndex != -1)
|
||||||
{
|
{
|
||||||
TrackedRecord<TObject>& oldRecord = oldCache.getValueAt(oldIndex);
|
TrackedRecord<TObject>& oldRecord = oldCache.getValueAt(oldIndex);
|
||||||
|
if (oldRecord.state == RecordState::MODIFIED)
|
||||||
|
{
|
||||||
|
delete refreshedRecord.data;
|
||||||
|
cache.insert(id, oldRecord);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
*oldRecord.data = *refreshedRecord.data;
|
*oldRecord.data = *refreshedRecord.data;
|
||||||
oldRecord.slotIndex = refreshedRecord.slotIndex;
|
oldRecord.slotIndex = refreshedRecord.slotIndex;
|
||||||
oldRecord.state = refreshedRecord.state;
|
oldRecord.state = refreshedRecord.state;
|
||||||
|
|||||||
Reference in New Issue
Block a user