Fixed integrity problem with gone remote meta bundles

This commit is contained in:
Dennis Schwerdel 2017-03-30 17:50:52 +02:00 committed by Dennis Schwerdel
parent df2f407d96
commit 2f54f7b0c6
2 changed files with 8 additions and 1 deletions

View File

@ -269,10 +269,16 @@ impl BundleDb {
} }
#[inline] #[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) { if let Some(bundle) = self.local_bundles.remove(bundle) {
try!(fs::remove_file(&bundle.path).map_err(|e| BundleDbError::Remove(e, bundle.id()))) 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) { if let Some(bundle) = self.remote_bundles.remove(bundle) {
fs::remove_file(&bundle.path).map_err(|e| BundleDbError::Remove(e, bundle.id())) fs::remove_file(&bundle.path).map_err(|e| BundleDbError::Remove(e, bundle.id()))
} else { } else {

View File

@ -228,6 +228,7 @@ impl Repository {
fn remove_gone_remote_bundle(&mut self, bundle: BundleInfo) -> Result<(), RepositoryError> { fn remove_gone_remote_bundle(&mut self, bundle: BundleInfo) -> Result<(), RepositoryError> {
if let Some(id) = self.bundle_map.find(&bundle.id) { if let Some(id) = self.bundle_map.find(&bundle.id) {
info!("Removing bundle from index: {}", 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)); try!(self.index.filter(|_key, data| data.bundle != id));
self.bundle_map.remove(id); self.bundle_map.remove(id);
} }