From deba0cc09694222538d4811e905c8500232383a5 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Tue, 31 May 2022 10:23:46 +0200 Subject: [PATCH] Make v4::load_dump copy each part a the dump --- meilisearch-lib/src/dump/loaders/v4.rs | 32 +++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/meilisearch-lib/src/dump/loaders/v4.rs b/meilisearch-lib/src/dump/loaders/v4.rs index df7b33cfa..50fffeb9e 100644 --- a/meilisearch-lib/src/dump/loaders/v4.rs +++ b/meilisearch-lib/src/dump/loaders/v4.rs @@ -1,6 +1,9 @@ +use std::fs; use std::path::Path; +use fs_extra::dir::{self, CopyOptions}; use log::info; +use tempfile::tempdir; use crate::dump::Metadata; use crate::options::IndexerOpts; @@ -15,9 +18,36 @@ pub fn load_dump( ) -> anyhow::Result<()> { info!("Patching dump V4 to dump V5..."); + let patched_dir = tempdir()?; + let options = CopyOptions::default(); + + // Indexes + dir::copy(src.as_ref().join("indexes"), patched_dir.path(), &options)?; + + // Index uuids + dir::copy( + src.as_ref().join("index_uuids"), + patched_dir.path(), + &options, + )?; + + // Metadata + fs::copy( + src.as_ref().join("metadata.json"), + patched_dir.path().join("metadata.json"), + )?; + + // Updates + dir::copy(src.as_ref().join("updates"), patched_dir.path(), &options)?; + + // Keys + if src.as_ref().join("keys").exists() { + fs::copy(src.as_ref().join("keys"), patched_dir.path().join("keys"))?; + } + super::v5::load_dump( meta, - src, + patched_dir.path(), dst, index_db_size, meta_env_size,