mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
Make archive event pruning more robust
This commit is contained in:
parent
0c59a0d4d2
commit
490989ac2a
1 changed files with 22 additions and 4 deletions
|
|
@ -570,9 +570,10 @@ void TextEventManager::Impl::PruneArchives()
|
||||||
|
|
||||||
const std::unique_lock archiveEventKeyLock {archiveEventKeyMutex_};
|
const std::unique_lock archiveEventKeyLock {archiveEventKeyMutex_};
|
||||||
|
|
||||||
// If there are the same number of dates in both archiveEventKeys_ and
|
// If there are the same number of dates in archiveEventKeys_, archiveDates_
|
||||||
// archiveDates_, there is nothing to prune
|
// and unloadedProductMap_, there is nothing to prune
|
||||||
if (archiveEventKeys_.size() == archiveDates_.size())
|
if (archiveEventKeys_.size() == archiveDates_.size() &&
|
||||||
|
unloadedProductMap_.size() == archiveDates_.size())
|
||||||
{
|
{
|
||||||
// Nothing to prune
|
// Nothing to prune
|
||||||
return;
|
return;
|
||||||
|
|
@ -594,7 +595,6 @@ void TextEventManager::Impl::PruneArchives()
|
||||||
|
|
||||||
// The date is not in the list of recent dates, remove it
|
// The date is not in the list of recent dates, remove it
|
||||||
it = archiveEventKeys_.erase(it);
|
it = archiveEventKeys_.erase(it);
|
||||||
unloadedProductMap_.erase(date);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -606,6 +606,24 @@ void TextEventManager::Impl::PruneArchives()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto it = unloadedProductMap_.begin(); it != unloadedProductMap_.end();)
|
||||||
|
{
|
||||||
|
const auto& date = it->first;
|
||||||
|
|
||||||
|
// If date is not in recent days map
|
||||||
|
if (std::find(archiveDates_.cbegin(), archiveDates_.cend(), date) ==
|
||||||
|
archiveDates_.cend())
|
||||||
|
{
|
||||||
|
// The date is not in the list of recent dates, remove it
|
||||||
|
it = unloadedProductMap_.erase(it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The date is recent, keep it
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove elements from eventKeysToPrune if they are in eventKeysToKeep
|
// Remove elements from eventKeysToPrune if they are in eventKeysToKeep
|
||||||
for (const auto& eventKey : eventKeysToKeep)
|
for (const auto& eventKey : eventKeysToKeep)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue