From a3dc3eb37c18db16f381d7cfb70f5c65892c87eb Mon Sep 17 00:00:00 2001 From: Brooks Date: Wed, 6 Sep 2023 14:19:01 -0400 Subject: [PATCH] Takes inner HashSet when dropping CacheHashData (#33169) --- accounts-db/src/cache_hash_data.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/accounts-db/src/cache_hash_data.rs b/accounts-db/src/cache_hash_data.rs index fb50e2113d86ca..a86822eb85633d 100644 --- a/accounts-db/src/cache_hash_data.rs +++ b/accounts-db/src/cache_hash_data.rs @@ -226,12 +226,12 @@ impl CacheHashData { result } fn delete_old_cache_files(&self) { - let pre_existing_cache_files = self.pre_existing_cache_files.lock().unwrap(); - if !pre_existing_cache_files.is_empty() { + let old_cache_files = std::mem::take(&mut *self.pre_existing_cache_files.lock().unwrap()); + if !old_cache_files.is_empty() { self.stats .unused_cache_files - .fetch_add(pre_existing_cache_files.len(), Ordering::Relaxed); - for file_name in pre_existing_cache_files.iter() { + .fetch_add(old_cache_files.len(), Ordering::Relaxed); + for file_name in old_cache_files.iter() { let result = self.cache_dir.join(file_name); let _ = fs::remove_file(result); }