diff --git a/pbs-api-types/src/maintenance.rs b/pbs-api-types/src/maintenance.rs index 1e3413dc..a7b8b078 100644 --- a/pbs-api-types/src/maintenance.rs +++ b/pbs-api-types/src/maintenance.rs @@ -77,10 +77,9 @@ pub struct MaintenanceMode { } impl MaintenanceMode { - /// Used for deciding whether the datastore is cleared from the internal cache after the last - /// task finishes, so all open files are closed. - pub fn is_offline(&self) -> bool { - self.ty == MaintenanceType::Offline + /// Used for deciding whether the datastore is cleared from the internal cache + pub fn clear_from_cache(&self) -> bool { + self.ty == MaintenanceType::Offline || self.ty == MaintenanceType::Delete } pub fn check(&self, operation: Option) -> Result<(), Error> { diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index 2755fed8..2bf2b843 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -116,7 +116,8 @@ impl Drop for DataStore { && pbs_config::datastore::config() .and_then(|(s, _)| s.lookup::("datastore", self.name())) .map_or(false, |c| { - c.get_maintenance_mode().map_or(false, |m| m.is_offline()) + c.get_maintenance_mode() + .map_or(false, |m| m.clear_from_cache()) }); if remove_from_cache { @@ -216,7 +217,7 @@ impl DataStore { let datastore: DataStoreConfig = config.lookup("datastore", name)?; if datastore .get_maintenance_mode() - .map_or(false, |m| m.is_offline()) + .map_or(false, |m| m.clear_from_cache()) { // the datastore drop handler does the checking if tasks are running and clears the // cache entry, so we just have to trigger it here