drop disk index bucket files on drop by default (#33316)

This commit is contained in:
Jeff Washington (jwash) 2023-09-20 07:50:17 -07:00 committed by GitHub
parent df93145c97
commit cfd0a00ae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -79,6 +79,8 @@ pub struct BucketStorage<O: BucketOccupied> {
pub stats: Arc<BucketStats>,
pub max_search: MaxSearch,
pub contents: O,
/// true if when this bucket is dropped, the file should be deleted
pub delete_file_on_drop: bool,
}
#[derive(Debug)]
@ -88,7 +90,9 @@ pub enum BucketStorageError {
impl<O: BucketOccupied> Drop for BucketStorage<O> {
fn drop(&mut self) {
self.delete();
if self.delete_file_on_drop {
self.delete();
}
}
}
@ -157,6 +161,8 @@ impl<O: BucketOccupied> BucketStorage<O> {
stats,
max_search,
contents: O::new(capacity),
// by default, newly created files will get deleted when dropped
delete_file_on_drop: true,
},
file_name,
)