diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-10-04 16:36:40 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-10-07 17:32:35 +0200 |
commit | b189bf7b8cead0bd33190755d46e75f09584cd58 (patch) | |
tree | 318fb09bc8e590657749620cb8a1a65001fe5261 /libimagstore | |
parent | 1e83ad7bbd8834d555bb0e7387e824a2ea1fe503 (diff) |
Add check if entry is present
If we try to rename an entry that is borrowed, we fail, as renaming an
borrowed entry might result in some _really_ ugly bugs.
Diffstat (limited to 'libimagstore')
-rw-r--r-- | libimagstore/src/store.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index cbe7b54d..1320c51d 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -670,6 +670,13 @@ impl Store { return Err(SEK::EntryAlreadyExists.into_error()); } + // if we do not have an entry here, we fail in `FileAbstraction::rename()` below. + // if we have one, but it is borrowed, we really should not rename it, as this might + // lead to strange errors + if hsmap.get(&old_id).map(|e| e.is_borrowed()).unwrap_or(false) { + return Err(SEK::EntryAlreadyBorrowed.into_error()); + } + let old_id_pb = try!(old_id.clone().with_base(self.path().clone()).into_pathbuf()); let new_id_pb = try!(new_id.clone().with_base(self.path().clone()).into_pathbuf()); |