fix dumpv1

This commit is contained in:
mpostma 2021-09-29 12:34:39 +02:00 committed by Tamo
parent 44a2ff07b1
commit 03af99650d
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
4 changed files with 18 additions and 5 deletions

View file

@ -109,6 +109,15 @@ pub fn load_dump(
update_db_size: usize,
indexer_opts: &IndexerOpts,
) -> anyhow::Result<()> {
// Setup a temp directory path in the same path as the database, to prevent cross devices
// references.
let temp_path = dst_path.as_ref().parent().map(ToOwned::to_owned).unwrap_or_else(|| ".".into());
if cfg!(windows) {
std::env::set_var("TMP", temp_path);
} else {
std::env::set_var("TMPDIR", temp_path);
}
let tmp_src = tempfile::tempdir()?;
let tmp_src_path = tmp_src.path();
@ -120,6 +129,8 @@ pub fn load_dump(
let tmp_dst = tempfile::tempdir()?;
println!("temp path: {}", tmp_dst.path().display());
match meta {
Metadata::V1(meta) => {
meta.load_dump(&tmp_src_path, tmp_dst.path(), index_db_size, indexer_opts)?