mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-09 02:22:54 +00:00
feat: make garbage collection opt-out (#28)
This commit is contained in:
@@ -278,6 +278,12 @@ pub trait Directory: DirectoryClone + fmt::Debug + Send + Sync + 'static {
|
||||
) -> Option<Box<dyn MergePolicy>> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns true if this directory supports garbage collection. The default assumption is
|
||||
/// `true`
|
||||
fn supports_garbage_collection(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/// DirectoryClone
|
||||
|
||||
@@ -117,6 +117,13 @@ impl ManagedDirectory {
|
||||
&mut self,
|
||||
get_living_files: L,
|
||||
) -> crate::Result<GarbageCollectionResult> {
|
||||
if !self.supports_garbage_collection() {
|
||||
// the underlying directory does not support garbage collection.
|
||||
return Ok(GarbageCollectionResult {
|
||||
deleted_files: vec![],
|
||||
failed_to_delete_files: vec![],
|
||||
});
|
||||
}
|
||||
let mut files_to_delete = vec![];
|
||||
|
||||
// We're about to do an atomic write to managed.json, lock it down
|
||||
@@ -359,6 +366,10 @@ impl Directory for ManagedDirectory {
|
||||
self.directory
|
||||
.reconsider_merge_policy(metas, previous_metas)
|
||||
}
|
||||
|
||||
fn supports_garbage_collection(&self) -> bool {
|
||||
self.directory.supports_garbage_collection()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for ManagedDirectory {
|
||||
|
||||
Reference in New Issue
Block a user