Make v4::load_dump copy each part a the dump

This commit is contained in:
ManyTheFish 2022-05-31 10:23:46 +02:00
parent 26e7bdf702
commit deba0cc096
1 changed files with 31 additions and 1 deletions

View File

@ -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,