Fix: We cannot offer a Ref::delete(self), but a Ref::delete_by_hash()

We cannot offer the former because deleting self would always fail as
the FileLockEntry is already borrowed from the store, so the store
declines this.

But deleting by hash works.
This commit is contained in:
Matthias Beyer 2016-07-05 12:42:47 +02:00
parent 1211a99775
commit 55c39ac94d

View file

@ -56,12 +56,12 @@ impl<'a> Ref<'a> {
.map_err(|e| REK::StoreReadError.into_error_with_cause(e)) .map_err(|e| REK::StoreReadError.into_error_with_cause(e))
} }
/// Delete this ref /// Delete a ref by hash
/// ///
/// If the returned Result contains an error, the ref might not be deleted. /// If the returned Result contains an error, the ref might not be deleted.
pub fn delete(self, store: &'a Store) -> Result<()> { pub fn delete_by_hash(store: &'a Store, hash: String) -> Result<()> {
store store
.delete(self.0.get_location().clone()) .delete(ModuleEntryPath::new(hash).into_storeid())
.map_err(Box::new) .map_err(Box::new)
.map_err(|e| REK::StoreWriteError.into_error_with_cause(e)) .map_err(|e| REK::StoreWriteError.into_error_with_cause(e))
} }