datastore: move blob loading into BackupDir impl and adapt call sites

data blobs can only appear in a BackupDir (snapshot) in the backup
hierachy, so makes more sense that it lives in there.

As it wasn't widely used anyway it's easy to move the single
non-package call site over to the new one directly and drop the
implementation from Datastore completely.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht
2022-04-24 19:09:38 +02:00
parent f03649b8f3
commit 1eef52c206
3 changed files with 16 additions and 16 deletions

View File

@ -11,7 +11,7 @@ use pbs_api_types::{BackupType, GroupFilter, BACKUP_DATE_REGEX, BACKUP_FILE_REGE
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)]
@ -345,6 +345,18 @@ impl BackupDir {
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