use pbs_config::{open_backup_lockfile, BackupLockGuard};
use crate::manifest::{MANIFEST_BLOB_NAME, MANIFEST_LOCK_NAME};
-use crate::DataStore;
+use crate::{DataStore, DataBlob};
/// BackupGroup is a directory containing a list of BackupDir
#[derive(Clone)]
proxmox_time::epoch_to_rfc3339_utc(backup_time)
}
+ /// load a `DataBlob` from this snapshot's backup dir.
+ pub fn load_blob(&self, filename: &str) -> Result<DataBlob, Error> {
+ let mut path = self.full_path();
+ path.push(filename);
+
+ proxmox_lang::try_block!({
+ let mut file = std::fs::File::open(&path)?;
+ DataBlob::load_from_reader(&mut file)
+ })
+ .map_err(|err| format_err!("unable to load blob '{:?}' - {}", path, err))
+ }
+
/// Returns the filename to lock a manifest
///
/// Also creates the basedir. The lockfile is located in
self.inner.chunk_store.insert_chunk(chunk, digest)
}
- pub fn load_blob(&self, backup_dir: &BackupDir, filename: &str) -> Result<DataBlob, Error> {
- let mut path = backup_dir.full_path();
- path.push(filename);
-
- proxmox_lang::try_block!({
- let mut file = std::fs::File::open(&path)?;
- DataBlob::load_from_reader(&mut file)
- })
- .map_err(|err| format_err!("unable to load blob '{:?}' - {}", path, err))
- }
-
pub fn stat_chunk(&self, digest: &[u8; 32]) -> Result<std::fs::Metadata, Error> {
let (chunk_path, _digest_str) = self.inner.chunk_store.chunk_path(digest);
std::fs::metadata(chunk_path).map_err(Error::from)
/// Load the manifest without a lock. Must not be written back.
pub fn load_manifest(&self, backup_dir: &BackupDir) -> Result<(BackupManifest, u64), Error> {
- let blob = self.load_blob(backup_dir, MANIFEST_BLOB_NAME)?;
+ let blob = backup_dir.load_blob(MANIFEST_BLOB_NAME)?;
let raw_size = blob.raw_size();
let manifest = BackupManifest::try_from(blob)?;
Ok((manifest, raw_size))
}
fn verify_blob(
- datastore: Arc<DataStore>,
backup_dir: &BackupDir,
info: &FileInfo,
) -> Result<(), Error> {
- let blob = datastore.load_blob(backup_dir, &info.filename)?;
+ let blob = backup_dir.load_blob(&info.filename)?;
let raw_size = blob.raw_size();
if raw_size != info.size {
match archive_type(&info.filename)? {
ArchiveType::FixedIndex => verify_fixed_index(verify_worker, backup_dir, info),
ArchiveType::DynamicIndex => verify_dynamic_index(verify_worker, backup_dir, info),
- ArchiveType::Blob => verify_blob(verify_worker.datastore.clone(), backup_dir, info),
+ ArchiveType::Blob => verify_blob(backup_dir, info),
}
});