Takes inner HashSet when dropping CacheHashData (#33169)

This commit is contained in:
Brooks 2023-09-06 14:19:01 -04:00 committed by GitHub
parent a80819b029
commit a3dc3eb37c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -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);
}