move some tools used by the client

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2021-07-09 14:10:15 +02:00
parent 75f83c6a81
commit ba0ccc5991
6 changed files with 40 additions and 34 deletions

View File

@ -16,8 +16,7 @@ use pbs_datastore::dynamic_index::DynamicIndexReader;
use pbs_datastore::fixed_index::FixedIndexReader;
use pbs_datastore::index::IndexFile;
use pbs_datastore::manifest::MANIFEST_BLOB_NAME;
use crate::tools::compute_file_csum;
use pbs_tools::sha::sha256;
use super::{HttpClient, H2Client};
@ -163,7 +162,8 @@ impl BackupReader {
self.download(name, &mut tmpfile).await?;
let (csum, size) = compute_file_csum(&mut tmpfile)?;
tmpfile.seek(SeekFrom::Start(0))?;
let (csum, size) = sha256(&mut tmpfile)?;
manifest.verify_file(name, &csum, size)?;
tmpfile.seek(SeekFrom::Start(0))?;

View File

@ -13,13 +13,14 @@ use serde_json::json;
use proxmox::api::error::{HttpError, StatusCode};
use pbs_datastore::task_log;
use pbs_tools::sha::sha256;
use crate::{
api2::types::*,
backup::*,
client::*,
server::WorkerTask,
tools::{compute_file_csum, ParallelHandler},
tools::ParallelHandler,
};
// fixme: implement filters
@ -215,7 +216,8 @@ async fn pull_single_archive(
.await?;
}
ArchiveType::Blob => {
let (csum, size) = compute_file_csum(&mut tmpfile)?;
tmpfile.seek(SeekFrom::Start(0))?;
let (csum, size) = sha256(&mut tmpfile)?;
verify_archive(archive_info, &csum, size)?;
}
}
@ -357,7 +359,7 @@ async fn pull_snapshot(
}
ArchiveType::Blob => {
let mut tmpfile = std::fs::File::open(&path)?;
let (csum, size) = compute_file_csum(&mut tmpfile)?;
let (csum, size) = sha256(&mut tmpfile)?;
match manifest.verify_file(&item.filename, &csum, size) {
Ok(_) => continue,
Err(err) => {