diff --git a/dump/src/reader/v6/mod.rs b/dump/src/reader/v6/mod.rs index 4b08c6f8d..aa3f4c966 100644 --- a/dump/src/reader/v6/mod.rs +++ b/dump/src/reader/v6/mod.rs @@ -1,5 +1,5 @@ use std::fs::{self, File}; -use std::io::{BufRead, BufReader}; +use std::io::{BufRead, BufReader, ErrorKind}; use std::path::Path; use std::str::FromStr; @@ -44,7 +44,7 @@ pub type Code = meilisearch_types::error::Code; pub struct V6Reader { dump: TempDir, - instance_uid: Uuid, + instance_uid: Option, metadata: Metadata, tasks: BufReader, keys: BufReader, @@ -53,8 +53,11 @@ pub struct V6Reader { impl V6Reader { pub fn open(dump: TempDir) -> Result { let meta_file = fs::read(dump.path().join("metadata.json"))?; - let instance_uid = fs::read_to_string(dump.path().join("instance_uid.uuid"))?; - let instance_uid = Uuid::from_str(&instance_uid)?; + let instance_uid = match fs::read_to_string(dump.path().join("instance_uid.uuid")) { + Ok(uuid) => Some(Uuid::parse_str(&uuid)?), + Err(e) if e.kind() == ErrorKind::NotFound => None, + Err(e) => return Err(e.into()), + }; Ok(V6Reader { metadata: serde_json::from_reader(&*meta_file)?, @@ -74,7 +77,7 @@ impl V6Reader { } pub fn instance_uid(&self) -> Result> { - Ok(Some(self.instance_uid)) + Ok(self.instance_uid) } pub fn indexes(&self) -> Result> + '_>> {