reference the datastore in BackupGroup/Dir
And drop the base_path parameter on a first bunch of functions (more reordering will follow). Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
@ -4,6 +4,7 @@ use std::collections::HashSet;
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use futures::*;
|
||||
@ -182,7 +183,7 @@ pub fn list_groups(
|
||||
return Ok(group_info);
|
||||
}
|
||||
|
||||
let snapshots = match group.list_backups(&datastore.base_path()) {
|
||||
let snapshots = match group.list_backups() {
|
||||
Ok(snapshots) => snapshots,
|
||||
Err(_) => return Ok(group_info),
|
||||
};
|
||||
@ -294,7 +295,7 @@ pub fn list_snapshot_files(
|
||||
PRIV_DATASTORE_AUDIT | PRIV_DATASTORE_READ,
|
||||
)?;
|
||||
|
||||
let info = BackupInfo::new(&datastore.base_path(), snapshot)?;
|
||||
let info = BackupInfo::new(snapshot)?;
|
||||
|
||||
let (_manifest, files) = get_all_snapshot_files(&datastore, &info)?;
|
||||
|
||||
@ -405,7 +406,7 @@ pub fn list_snapshots(
|
||||
group: group.into(),
|
||||
time: info.backup_dir.backup_time(),
|
||||
};
|
||||
let protected = info.backup_dir.is_protected(datastore.base_path());
|
||||
let protected = info.backup_dir.is_protected();
|
||||
|
||||
match get_all_snapshot_files(&datastore, &info) {
|
||||
Ok((manifest, files)) => {
|
||||
@ -488,7 +489,7 @@ pub fn list_snapshots(
|
||||
return Ok(snapshots);
|
||||
}
|
||||
|
||||
let group_backups = group.list_backups(&datastore.base_path())?;
|
||||
let group_backups = group.list_backups()?;
|
||||
|
||||
snapshots.extend(
|
||||
group_backups
|
||||
@ -500,7 +501,10 @@ pub fn list_snapshots(
|
||||
})
|
||||
}
|
||||
|
||||
fn get_snapshots_count(store: &DataStore, filter_owner: Option<&Authid>) -> Result<Counts, Error> {
|
||||
fn get_snapshots_count(
|
||||
store: &Arc<DataStore>,
|
||||
filter_owner: Option<&Authid>,
|
||||
) -> Result<Counts, Error> {
|
||||
store
|
||||
.iter_backup_groups_ok()?
|
||||
.filter(|group| {
|
||||
@ -519,7 +523,7 @@ fn get_snapshots_count(store: &DataStore, filter_owner: Option<&Authid>) -> Resu
|
||||
}
|
||||
})
|
||||
.try_fold(Counts::default(), |mut counts, group| {
|
||||
let snapshot_count = group.list_backups(&store.base_path())?.len() as u64;
|
||||
let snapshot_count = group.list_backups()?.len() as u64;
|
||||
|
||||
// only include groups with snapshots, counting/displaying emtpy groups can confuse
|
||||
if snapshot_count > 0 {
|
||||
@ -788,7 +792,7 @@ pub fn prune(
|
||||
|
||||
let mut prune_result = Vec::new();
|
||||
|
||||
let list = group.list_backups(&datastore.base_path())?;
|
||||
let list = group.list_backups()?;
|
||||
|
||||
let mut prune_info = compute_prune_info(list, &prune_options)?;
|
||||
|
||||
@ -1797,7 +1801,7 @@ pub fn get_protection(
|
||||
PRIV_DATASTORE_AUDIT,
|
||||
)?;
|
||||
|
||||
Ok(backup_dir.is_protected(datastore.base_path()))
|
||||
Ok(backup_dir.is_protected())
|
||||
}
|
||||
|
||||
#[api(
|
||||
|
@ -133,9 +133,7 @@ fn upgrade_to_backup_protocol(
|
||||
}
|
||||
|
||||
let last_backup = {
|
||||
let info = backup_group
|
||||
.last_backup(&datastore.base_path(), true)
|
||||
.unwrap_or(None);
|
||||
let info = backup_group.last_backup(true).unwrap_or(None);
|
||||
if let Some(info) = info {
|
||||
let (manifest, _) = datastore.load_manifest(&info.backup_dir)?;
|
||||
let verify = manifest.unprotected["verify_state"].clone();
|
||||
|
@ -123,7 +123,7 @@ fn upgrade_to_backup_reader_protocol(
|
||||
}
|
||||
|
||||
let _guard = lock_dir_noblock_shared(
|
||||
&backup_dir.full_path(datastore.base_path()),
|
||||
&backup_dir.full_path(),
|
||||
"snapshot",
|
||||
"locked by another operation",
|
||||
)?;
|
||||
|
@ -458,7 +458,7 @@ fn backup_worker(
|
||||
progress.done_snapshots = 0;
|
||||
progress.group_snapshots = 0;
|
||||
|
||||
let snapshot_list = group.list_backups(&datastore.base_path())?;
|
||||
let snapshot_list = group.list_backups()?;
|
||||
|
||||
// filter out unfinished backups
|
||||
let mut snapshot_list: Vec<_> = snapshot_list
|
||||
|
@ -450,7 +450,7 @@ pub fn verify_backup_group(
|
||||
filter: Option<&dyn Fn(&BackupManifest) -> bool>,
|
||||
) -> Result<Vec<String>, Error> {
|
||||
let mut errors = Vec::new();
|
||||
let mut list = match group.list_backups(&verify_worker.datastore.base_path()) {
|
||||
let mut list = match group.list_backups() {
|
||||
Ok(list) => list,
|
||||
Err(err) => {
|
||||
task_log!(
|
||||
|
@ -44,7 +44,7 @@ pub fn prune_datastore(
|
||||
|
||||
for group in datastore.iter_backup_groups()? {
|
||||
let group = group?;
|
||||
let list = group.list_backups(&datastore.base_path())?;
|
||||
let list = group.list_backups()?;
|
||||
|
||||
if !has_privs && !datastore.owns_backup(group.as_ref(), &auth_id)? {
|
||||
continue;
|
||||
|
@ -663,13 +663,13 @@ pub async fn pull_group(
|
||||
|
||||
if params.remove_vanished {
|
||||
let group = params.store.backup_group(group.clone());
|
||||
let local_list = group.list_backups(¶ms.store.base_path())?;
|
||||
let local_list = group.list_backups()?;
|
||||
for info in local_list {
|
||||
let backup_time = info.backup_dir.backup_time();
|
||||
if remote_snapshots.contains(&backup_time) {
|
||||
continue;
|
||||
}
|
||||
if info.backup_dir.is_protected(params.store.base_path()) {
|
||||
if info.backup_dir.is_protected() {
|
||||
task_log!(
|
||||
worker,
|
||||
"don't delete vanished snapshot {:?} (protected)",
|
||||
|
Reference in New Issue
Block a user