Fix: Remove call to deprecated function
This actually caused tests to fail if there was indeed a file at /tmp/store/test and the test tried to create a "test" entry in the store. Do use backend instead to check whether entry actually exists. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
42247170a6
commit
6751c34f1b
1 changed files with 16 additions and 9 deletions
|
@ -229,10 +229,16 @@ impl Store {
|
||||||
|
|
||||||
debug!("Creating id: '{}'", id);
|
debug!("Creating id: '{}'", id);
|
||||||
|
|
||||||
let exists = id.exists()? || self.entries
|
let exists = self.entries
|
||||||
.read()
|
.read()
|
||||||
.map(|map| map.contains_key(&id))
|
|
||||||
.map_err(|_| SE::from_kind(SEK::LockPoisoned))
|
.map_err(|_| SE::from_kind(SEK::LockPoisoned))
|
||||||
|
.map(|map| map.contains_key(&id))
|
||||||
|
.and_then(|exists| if exists {
|
||||||
|
Ok(exists)
|
||||||
|
} else {
|
||||||
|
let pb = id.clone().into_pathbuf().map_err(SE::from)?;
|
||||||
|
self.backend.exists(&pb)
|
||||||
|
})
|
||||||
.chain_err(|| SEK::CreateCallError(id.clone()))?;
|
.chain_err(|| SEK::CreateCallError(id.clone()))?;
|
||||||
|
|
||||||
if exists {
|
if exists {
|
||||||
|
@ -314,10 +320,16 @@ impl Store {
|
||||||
|
|
||||||
debug!("Getting id: '{}'", id);
|
debug!("Getting id: '{}'", id);
|
||||||
|
|
||||||
let exists = id.exists()? || self.entries
|
let exists = self.entries
|
||||||
.read()
|
.read()
|
||||||
.map(|map| map.contains_key(&id))
|
|
||||||
.map_err(|_| SE::from_kind(SEK::LockPoisoned))
|
.map_err(|_| SE::from_kind(SEK::LockPoisoned))
|
||||||
|
.map(|map| map.contains_key(&id))
|
||||||
|
.and_then(|exists| if exists {
|
||||||
|
Ok(exists)
|
||||||
|
} else {
|
||||||
|
let pb = id.clone().into_pathbuf().map_err(SE::from)?;
|
||||||
|
self.backend.exists(&pb)
|
||||||
|
})
|
||||||
.chain_err(|| SEK::GetCallError(id.clone()))?;
|
.chain_err(|| SEK::GetCallError(id.clone()))?;
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
|
@ -461,12 +473,7 @@ impl Store {
|
||||||
|
|
||||||
debug!("Deleting id: '{}'", id);
|
debug!("Deleting id: '{}'", id);
|
||||||
|
|
||||||
// Small optimization: We need the pathbuf for deleting, but when calling
|
|
||||||
// StoreId::exists(), a PathBuf object gets allocated. So we simply get a
|
|
||||||
// PathBuf here, check whether it is there and if it is, we can re-use it to
|
|
||||||
// delete the filesystem file.
|
|
||||||
let pb = id.clone().into_pathbuf()?;
|
let pb = id.clone().into_pathbuf()?;
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut entries = self
|
let mut entries = self
|
||||||
.entries
|
.entries
|
||||||
|
|
Loading…
Reference in a new issue