diff --git a/util/src/keys/directory.rs b/util/src/keys/directory.rs index 8ebf2c27d..9c01d1974 100644 --- a/util/src/keys/directory.rs +++ b/util/src/keys/directory.rs @@ -517,7 +517,7 @@ impl KeyDirectory { let cache = self.cache.borrow(); cache.keys().cloned().filter(|key| !uniqs.contains(key)).collect() }; - if removes.is_empty() { return } + if removes.is_empty() { return; } let mut cache = self.cache.borrow_mut(); for key in removes { cache.remove(&key); } } @@ -1093,6 +1093,14 @@ mod directory_tests { // since all keys are different, should be exactly MAX_CACHE_USAGE_TRACK assert_eq!(MAX_CACHE_USAGE_TRACK, directory.cache_size()) } + + #[test] + fn collects_garbage_on_empty() { + let temp_path = RandomTempPath::create_dir(); + let mut directory = KeyDirectory::new(&temp_path.as_path()); + directory.collect_garbage(); + assert_eq!(0, directory.cache_size()) + } } #[cfg(test)]