hierachy: ListAccessibleBackupGroups make store also a lifetime'd ref
avoid some extra Arc::clone, even if they're not really expensive (just some atomics) Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
cbde538c0c
commit
7da520ae46
|
@ -599,7 +599,7 @@ pub fn list_snapshots(
|
||||||
|
|
||||||
fn get_snapshots_count(store: &Arc<DataStore>, owner: Option<&Authid>) -> Result<Counts, Error> {
|
fn get_snapshots_count(store: &Arc<DataStore>, owner: Option<&Authid>) -> Result<Counts, Error> {
|
||||||
let root_ns = Default::default();
|
let root_ns = Default::default();
|
||||||
ListAccessibleBackupGroups::new(Arc::clone(store), root_ns, MAX_NAMESPACE_DEPTH, owner)?
|
ListAccessibleBackupGroups::new(store, root_ns, MAX_NAMESPACE_DEPTH, owner)?
|
||||||
.try_fold(Counts::default(), |mut counts, group| {
|
.try_fold(Counts::default(), |mut counts, group| {
|
||||||
let group = match group {
|
let group = match group {
|
||||||
Ok(group) => group,
|
Ok(group) => group,
|
||||||
|
@ -1059,7 +1059,7 @@ pub fn prune_datastore(
|
||||||
|
|
||||||
let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
|
let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
|
||||||
|
|
||||||
// FIXME: also allow a per-namespace pruning with max-depth
|
// FIXME: add max-depth
|
||||||
|
|
||||||
let upid_str = WorkerTask::new_thread(
|
let upid_str = WorkerTask::new_thread(
|
||||||
"prune",
|
"prune",
|
||||||
|
|
|
@ -14,7 +14,7 @@ use pbs_datastore::{backup_info::BackupGroup, DataStore, ListGroups, ListNamespa
|
||||||
/// Is basically just a filter-iter for pbs_datastore::ListNamespacesRecursive including access and
|
/// Is basically just a filter-iter for pbs_datastore::ListNamespacesRecursive including access and
|
||||||
/// optional owner checks.
|
/// optional owner checks.
|
||||||
pub struct ListAccessibleBackupGroups<'a> {
|
pub struct ListAccessibleBackupGroups<'a> {
|
||||||
store: Arc<DataStore>,
|
store: &'a Arc<DataStore>,
|
||||||
auth_id: Option<&'a Authid>,
|
auth_id: Option<&'a Authid>,
|
||||||
user_info: Arc<CachedUserInfo>,
|
user_info: Arc<CachedUserInfo>,
|
||||||
state: Option<ListGroups>,
|
state: Option<ListGroups>,
|
||||||
|
@ -25,12 +25,12 @@ impl<'a> ListAccessibleBackupGroups<'a> {
|
||||||
// TODO: builder pattern
|
// TODO: builder pattern
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
store: Arc<DataStore>,
|
store: &'a Arc<DataStore>,
|
||||||
ns: BackupNamespace,
|
ns: BackupNamespace,
|
||||||
max_depth: usize,
|
max_depth: usize,
|
||||||
auth_id: Option<&'a Authid>,
|
auth_id: Option<&'a Authid>,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let ns_iter = ListNamespacesRecursive::new_max_depth(Arc::clone(&store), ns, max_depth)?;
|
let ns_iter = ListNamespacesRecursive::new_max_depth(Arc::clone(store), ns, max_depth)?;
|
||||||
Ok(ListAccessibleBackupGroups {
|
Ok(ListAccessibleBackupGroups {
|
||||||
auth_id,
|
auth_id,
|
||||||
ns_iter,
|
ns_iter,
|
||||||
|
|
|
@ -518,7 +518,7 @@ pub fn verify_all_backups(
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: This should probably simply enable recursion (or the call have a recursion parameter)
|
// FIXME: This should probably simply enable recursion (or the call have a recursion parameter)
|
||||||
let store = Arc::clone(&verify_worker.datastore);
|
let store = &verify_worker.datastore;
|
||||||
let max_depth = max_depth.unwrap_or(pbs_api_types::MAX_NAMESPACE_DEPTH);
|
let max_depth = max_depth.unwrap_or(pbs_api_types::MAX_NAMESPACE_DEPTH);
|
||||||
|
|
||||||
let mut list = match ListAccessibleBackupGroups::new(store, ns.clone(), max_depth, owner) {
|
let mut list = match ListAccessibleBackupGroups::new(store, ns.clone(), max_depth, owner) {
|
||||||
|
|
Loading…
Reference in New Issue