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

View File

@ -1,6 +1,9 @@
use std::fs;
use std::path::Path; use std::path::Path;
use fs_extra::dir::{self, CopyOptions};
use log::info; use log::info;
use tempfile::tempdir;
use crate::dump::Metadata; use crate::dump::Metadata;
use crate::options::IndexerOpts; use crate::options::IndexerOpts;
@ -15,9 +18,36 @@ pub fn load_dump(
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
info!("Patching dump V4 to dump V5..."); 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( super::v5::load_dump(
meta, meta,
src, patched_dir.path(),
dst, dst,
index_db_size, index_db_size,
meta_env_size, meta_env_size,