@@ -2956,6 +2956,37 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
29562956 }
29572957 }
29582958
2959+ /// Enable or disable deleting obsolete files.
2960+ ///
2961+ /// false:
2962+ /// Suspend deleting obsolete files. Compactions will continue to occur,
2963+ /// but no obsolete files will be deleted. To resume file deletions, each
2964+ /// call to DisableFileDeletions() must be matched by a subsequent call to
2965+ /// EnableFileDeletions(). For more details, see EnableFileDeletions().
2966+ ///
2967+ /// true:
2968+ /// Resume deleting obsolete files, following up on `DisableFileDeletions()`.
2969+ /// File deletions disabling and enabling is not controlled by a binary flag,
2970+ /// instead it's represented as a counter to allow different callers to
2971+ /// independently disable file deletion. Disabling file deletion can be
2972+ /// critical for operations like making a backup. So the counter implementation
2973+ /// makes the file deletion disabled as long as there is one caller requesting
2974+ /// so, and only when every caller agrees to re-enable file deletion, it will
2975+ /// be enabled. Two threads can call this method concurrently without
2976+ /// synchronization -- i.e., file deletions will be enabled only after both
2977+ /// threads call EnableFileDeletions()
2978+ #[ inline]
2979+ pub fn enable_deletions ( & self , enable : bool ) -> Result < ( ) , Error > {
2980+ unsafe {
2981+ if enable {
2982+ ffi_try ! ( ffi:: rocksdb_enable_file_deletions( self . inner. inner( ) ) ) ;
2983+ } else {
2984+ ffi_try ! ( ffi:: rocksdb_disable_file_deletions( self . inner. inner( ) ) ) ;
2985+ }
2986+ }
2987+ Ok ( ( ) )
2988+ }
2989+
29592990 pub fn set_options ( & self , opts : & [ ( & str , & str ) ] ) -> Result < ( ) , Error > {
29602991 let copts = convert_options ( opts) ?;
29612992 let cnames: Vec < * const c_char > = copts. iter ( ) . map ( |opt| opt. 0 . as_ptr ( ) ) . collect ( ) ;
0 commit comments