Prevent overwriting local object (#130)
* Throw error when attempting to http fetch local object * clippy
This commit is contained in:
parent
6814ff1932
commit
1c29f4e66b
1 changed files with 9 additions and 1 deletions
|
@ -92,7 +92,7 @@ where
|
|||
// object found in database
|
||||
if let Some(object) = db_object {
|
||||
if let Some(last_refreshed_at) = object.last_refreshed_at() {
|
||||
let is_local = data.config.is_local_url(&self.0);
|
||||
let is_local = self.is_local(data);
|
||||
if !is_local && should_refetch_object(last_refreshed_at) {
|
||||
// object is outdated and should be refetched
|
||||
return self.dereference_from_http(data, Some(object)).await;
|
||||
|
@ -175,6 +175,14 @@ where
|
|||
let res = res?;
|
||||
let redirect_url = &res.url;
|
||||
|
||||
// Prevent overwriting local object
|
||||
if data.config.is_local_url(redirect_url) {
|
||||
return self
|
||||
.dereference_from_db(data)
|
||||
.await?
|
||||
.ok_or(Error::NotFound.into());
|
||||
}
|
||||
|
||||
Box::pin(Kind::verify(&res.object, redirect_url, data)).await?;
|
||||
Box::pin(Kind::from_json(res.object, data)).await
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue