prune: allow passing namespace

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-05-06 11:27:15 +02:00
parent a7f5e64154
commit 2f5417f845
2 changed files with 13 additions and 6 deletions

View File

@ -1007,6 +1007,10 @@ pub fn prune(
store: {
schema: DATASTORE_SCHEMA,
},
ns: {
type: BackupNamespace,
optional: true,
},
},
},
returns: {
@ -1022,6 +1026,7 @@ pub fn prune_datastore(
dry_run: bool,
prune_options: PruneOptions,
store: String,
ns: Option<BackupNamespace>,
_param: Value,
rpcenv: &mut dyn RpcEnvironment,
) -> Result<String, Error> {
@ -1043,8 +1048,8 @@ pub fn prune_datastore(
worker,
auth_id,
prune_options,
&store,
datastore,
ns.unwrap_or_default(),
dry_run,
)
},

View File

@ -4,7 +4,7 @@ use anyhow::Error;
use proxmox_sys::{task_log, task_warn};
use pbs_api_types::{Authid, Operation, PruneOptions, PRIV_DATASTORE_MODIFY};
use pbs_api_types::{Authid, BackupNamespace, Operation, PruneOptions, PRIV_DATASTORE_MODIFY};
use pbs_config::CachedUserInfo;
use pbs_datastore::prune::compute_prune_info;
use pbs_datastore::DataStore;
@ -16,10 +16,12 @@ pub fn prune_datastore(
worker: Arc<WorkerTask>,
auth_id: Authid,
prune_options: PruneOptions,
store: &str,
datastore: Arc<DataStore>,
ns: BackupNamespace,
//max_depth: Option<usize>, // FIXME
dry_run: bool,
) -> Result<(), Error> {
let store = &datastore.name();
task_log!(worker, "Starting datastore prune on store \"{}\"", store);
if dry_run {
@ -42,8 +44,8 @@ pub fn prune_datastore(
let privs = user_info.lookup_privs(&auth_id, &["datastore", store]);
let has_privs = privs & PRIV_DATASTORE_MODIFY != 0;
// FIXME: Namespaces and recursion!
for group in datastore.iter_backup_groups(Default::default())? {
// FIXME: Namespace recursion!
for group in datastore.iter_backup_groups(ns)? {
let group = group?;
let list = group.list_backups()?;
@ -115,8 +117,8 @@ pub fn do_prune_job(
worker.clone(),
auth_id,
prune_options,
&store,
datastore,
BackupNamespace::default(),
false,
);