From 9ffdadfc8df6719542861466234a7dac2f9707c9 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 4 Dec 2023 15:54:47 +0100 Subject: [PATCH] Add ObjectId::dereference_forced --- src/fetch/object_id.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/fetch/object_id.rs b/src/fetch/object_id.rs index 209960b..248d9ba 100644 --- a/src/fetch/object_id.rs +++ b/src/fetch/object_id.rs @@ -112,6 +112,22 @@ where } } + /// If this is a remote object, fetch it from origin instance unconditionally to get the + /// latest version, regardless of refresh interval. + pub async fn dereference_forced( + &self, + data: &Data<::DataType>, + ) -> Result::Error> + where + ::Error: From, + { + if data.config.is_local_url(&self.0) { + self.dereference_from_db(data).await.map(|o| o.ok_or(Error::NotFound.into()))? + } else { + self.dereference_from_http(data, None).await + } + } + /// Fetch an object from the local db. Instead of falling back to http, this throws an error if /// the object is not found in the database. pub async fn dereference_local(