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.
This commit is contained in:
parent
1e83ad7bbd
commit
b189bf7b8c
1 changed files with 7 additions and 0 deletions
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in a new issue