From 6814ff1932d84692416429efa88a9a6dd078b193 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Fri, 8 Nov 2024 13:37:55 +0100 Subject: [PATCH] If dereference fails, return object from local db instead (#129) --- src/fetch/object_id.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/fetch/object_id.rs b/src/fetch/object_id.rs index 3f0676b..424c22c 100644 --- a/src/fetch/object_id.rs +++ b/src/fetch/object_id.rs @@ -120,6 +120,7 @@ where .await .map(|o| o.ok_or(Error::NotFound.into()))? } 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 } } @@ -167,6 +168,10 @@ where 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 redirect_url = &res.url;