From a01a2c18f879bf9b5426279a0aa3abcc7e2b7746 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 17 Sep 2017 15:44:19 +0200 Subject: [PATCH] Check in Store::move_by_id() whether target exists, not only in cache but also on FS --- lib/core/libimagstore/src/store.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/core/libimagstore/src/store.rs b/lib/core/libimagstore/src/store.rs index 7b48e500..5ba3754f 100644 --- a/lib/core/libimagstore/src/store.rs +++ b/lib/core/libimagstore/src/store.rs @@ -755,6 +755,10 @@ impl Store { 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()); + if try!(self.backend.exists(&new_id_pb)) { + return Err(SE::from_kind(SEK::EntryAlreadyExists(new_id.clone()))); + } + match self.backend.rename(&old_id_pb, &new_id_pb) { Err(e) => return Err(e).chain_err(|| SEK::EntryRenameError(old_id_pb, new_id_pb)), Ok(_) => {