mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:50:06 +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_}; | ||||
| 
 | ||||
|    // If there are the same number of dates in both archiveEventKeys_ and
 | ||||
|    // archiveDates_, there is nothing to prune
 | ||||
|    if (archiveEventKeys_.size() == archiveDates_.size()) | ||||
|    // If there are the same number of dates in archiveEventKeys_, archiveDates_
 | ||||
|    // and unloadedProductMap_, there is nothing to prune
 | ||||
|    if (archiveEventKeys_.size() == archiveDates_.size() && | ||||
|        unloadedProductMap_.size() == archiveDates_.size()) | ||||
|    { | ||||
|       // Nothing to prune
 | ||||
|       return; | ||||
|  | @ -594,7 +595,6 @@ void TextEventManager::Impl::PruneArchives() | |||
| 
 | ||||
|          // The date is not in the list of recent dates, remove it
 | ||||
|          it = archiveEventKeys_.erase(it); | ||||
|          unloadedProductMap_.erase(date); | ||||
|       } | ||||
|       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
 | ||||
|    for (const auto& eventKey : eventKeysToKeep) | ||||
|    { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat