From 8a11c6c4291b1bcaa3ada62f15080d65e793a8b0 Mon Sep 17 00:00:00 2001 From: tamo Date: Mon, 24 May 2021 12:35:46 +0200 Subject: [PATCH] Implements the legacy behaviour of the dump When asked if a dump exists we check if it's the current dump, and if it's not then we check on the filesystem for any file matching our `uid.dump` --- .../src/index_controller/dump_actor/actor.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/meilisearch-http/src/index_controller/dump_actor/actor.rs b/meilisearch-http/src/index_controller/dump_actor/actor.rs index b41ddadcf..82a38cf96 100644 --- a/meilisearch-http/src/index_controller/dump_actor/actor.rs +++ b/meilisearch-http/src/index_controller/dump_actor/actor.rs @@ -182,12 +182,20 @@ where async fn handle_dump_info(&self, uid: String) -> DumpResult { match &*self.dump_info.lock().await { - None => Err(DumpError::DumpDoesNotExist(uid)), - Some(DumpInfo { uid: ref s, .. }) if &uid != s => Err(DumpError::DumpDoesNotExist(uid)), + None => self.dump_from_fs(uid).await, + Some(DumpInfo { uid: ref s, .. }) if &uid != s => self.dump_from_fs(uid).await, Some(info) => Ok(info.clone()), } } + async fn dump_from_fs(&self, uid: String) -> DumpResult { + self.dump_path + .join(format!("{}.dump", &uid)) + .exists() + .then(|| DumpInfo::new(uid.clone(), DumpStatus::Done)) + .ok_or(DumpError::DumpDoesNotExist(uid)) + } + async fn is_running(&self) -> bool { matches!( *self.dump_info.lock().await,