From 2f54f7b0c6ffdcb2ed018a3e4c944c192e219982 Mon Sep 17 00:00:00 2001 From: Dennis Schwerdel Date: Thu, 30 Mar 2017 17:50:52 +0200 Subject: [PATCH] Fixed integrity problem with gone remote meta bundles --- src/bundledb/db.rs | 8 +++++++- src/repository/mod.rs | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bundledb/db.rs b/src/bundledb/db.rs index d3e0f01..4de6852 100644 --- a/src/bundledb/db.rs +++ b/src/bundledb/db.rs @@ -269,10 +269,16 @@ impl BundleDb { } #[inline] - pub fn delete_bundle(&mut self, bundle: &BundleId) -> Result<(), BundleDbError> { + pub fn delete_local_bundle(&mut self, bundle: &BundleId) -> Result<(), BundleDbError> { if let Some(bundle) = self.local_bundles.remove(bundle) { try!(fs::remove_file(&bundle.path).map_err(|e| BundleDbError::Remove(e, bundle.id()))) } + Ok(()) + } + + #[inline] + pub fn delete_bundle(&mut self, bundle: &BundleId) -> Result<(), BundleDbError> { + try!(self.delete_local_bundle(bundle)); if let Some(bundle) = self.remote_bundles.remove(bundle) { fs::remove_file(&bundle.path).map_err(|e| BundleDbError::Remove(e, bundle.id())) } else { diff --git a/src/repository/mod.rs b/src/repository/mod.rs index 6c4b5a5..3febbd2 100644 --- a/src/repository/mod.rs +++ b/src/repository/mod.rs @@ -228,6 +228,7 @@ impl Repository { fn remove_gone_remote_bundle(&mut self, bundle: BundleInfo) -> Result<(), RepositoryError> { if let Some(id) = self.bundle_map.find(&bundle.id) { info!("Removing bundle from index: {}", bundle.id); + try!(self.bundles.delete_local_bundle(&bundle.id)); try!(self.index.filter(|_key, data| data.bundle != id)); self.bundle_map.remove(id); }