src/bin/proxmox-backup-client.rs: avoid loading catalog into memory
We can use the new DataBlobReader instead.
This commit is contained in:
parent
b791804f4b
commit
a84ef4c205
|
@ -6,7 +6,7 @@ use failure::*;
|
||||||
use chrono::{Local, Utc, TimeZone};
|
use chrono::{Local, Utc, TimeZone};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::collections::{HashSet, HashMap};
|
use std::collections::{HashSet, HashMap};
|
||||||
use std::io::Write;
|
use std::io::{BufReader, Write, Seek, SeekFrom};
|
||||||
use std::os::unix::fs::OpenOptionsExt;
|
use std::os::unix::fs::OpenOptionsExt;
|
||||||
|
|
||||||
use proxmox::tools::fs::{file_get_contents, file_get_json, file_set_contents, image_size};
|
use proxmox::tools::fs::{file_get_contents, file_get_json, file_set_contents, image_size};
|
||||||
|
@ -435,7 +435,7 @@ fn dump_catalog(
|
||||||
None => None,
|
None => None,
|
||||||
Some(path) => {
|
Some(path) => {
|
||||||
let (key, _) = load_and_decrtypt_key(&path, get_encryption_key_password)?;
|
let (key, _) = load_and_decrtypt_key(&path, get_encryption_key_password)?;
|
||||||
Some(Arc::new(CryptConfig::new(key)?))
|
Some(CryptConfig::new(key)?)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -447,18 +447,19 @@ fn dump_catalog(
|
||||||
&snapshot.group().backup_id(),
|
&snapshot.group().backup_id(),
|
||||||
snapshot.backup_time(), true).wait()?;
|
snapshot.backup_time(), true).wait()?;
|
||||||
|
|
||||||
let writer = Vec::with_capacity(1024*1024);
|
let blob_file = std::fs::OpenOptions::new()
|
||||||
let blob_data = client.download("catalog.blob", writer).wait()?;
|
.read(true)
|
||||||
let blob = DataBlob::from_raw(blob_data)?;
|
.write(true)
|
||||||
blob.verify_crc()?;
|
.custom_flags(libc::O_TMPFILE)
|
||||||
|
.open("/tmp")?;
|
||||||
|
|
||||||
let raw_data = match crypt_config {
|
let mut blob_file = client.download("catalog.blob", blob_file).wait()?;
|
||||||
Some(ref crypt_config) => blob.decode(Some(crypt_config))?,
|
|
||||||
None => blob.decode(None)?,
|
|
||||||
};
|
|
||||||
|
|
||||||
let slice = &raw_data[..];
|
blob_file.seek(SeekFrom::Start(0))?;
|
||||||
let mut catalog_reader = pxar::catalog::SimpleCatalogReader::new(slice);
|
|
||||||
|
let reader = BufReader::new(DataBlobReader::new(blob_file, crypt_config.as_ref())?);
|
||||||
|
|
||||||
|
let mut catalog_reader = pxar::catalog::SimpleCatalogReader::new(reader);
|
||||||
|
|
||||||
catalog_reader.dump()?;
|
catalog_reader.dump()?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue