If dereference fails, return object from local db instead (#129)
This commit is contained in:
parent
6dfd30a8ab
commit
6814ff1932
1 changed files with 5 additions and 0 deletions
|
@ -120,6 +120,7 @@ where
|
||||||
.await
|
.await
|
||||||
.map(|o| o.ok_or(Error::NotFound.into()))?
|
.map(|o| o.ok_or(Error::NotFound.into()))?
|
||||||
} else {
|
} else {
|
||||||
|
// Don't pass in any db object, otherwise it would be returned in case http fetch fails
|
||||||
self.dereference_from_http(data, None).await
|
self.dereference_from_http(data, None).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,6 +168,10 @@ where
|
||||||
return Err(Error::ObjectDeleted(url).into());
|
return Err(Error::ObjectDeleted(url).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If fetch failed, return the existing object from local database
|
||||||
|
if let (Err(_), Some(db_object)) = (&res, db_object) {
|
||||||
|
return Ok(db_object);
|
||||||
|
}
|
||||||
let res = res?;
|
let res = res?;
|
||||||
let redirect_url = &res.url;
|
let redirect_url = &res.url;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue