hierachy: add lifetime to ListAccessibleBackupGroups so that owner can be ref

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-05-13 16:48:56 +02:00
parent 74391d1c32
commit de27ebc6b6
3 changed files with 7 additions and 7 deletions

View File

@ -854,7 +854,7 @@ pub fn verify(
failed_dirs failed_dirs
} else { } else {
let owner = if owner_check_required { let owner = if owner_check_required {
Some(auth_id) Some(&auth_id)
} else { } else {
None None
}; };

View File

@ -13,22 +13,22 @@ 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 { pub struct ListAccessibleBackupGroups<'a> {
store: Arc<DataStore>, store: Arc<DataStore>,
auth_id: Option<Authid>, auth_id: Option<&'a Authid>,
user_info: Arc<CachedUserInfo>, user_info: Arc<CachedUserInfo>,
state: Option<ListGroups>, state: Option<ListGroups>,
ns_iter: ListNamespacesRecursive, ns_iter: ListNamespacesRecursive,
} }
impl ListAccessibleBackupGroups { impl <'a> ListAccessibleBackupGroups<'a> {
// TODO: builder pattern // TODO: builder pattern
pub fn new( pub fn new(
store: Arc<DataStore>, store: Arc<DataStore>,
ns: BackupNamespace, ns: BackupNamespace,
max_depth: usize, max_depth: usize,
auth_id: Option<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 {
@ -41,7 +41,7 @@ impl ListAccessibleBackupGroups {
} }
} }
impl Iterator for ListAccessibleBackupGroups { impl <'a> Iterator for ListAccessibleBackupGroups<'a> {
type Item = Result<BackupGroup, Error>; type Item = Result<BackupGroup, Error>;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {

View File

@ -498,7 +498,7 @@ pub fn verify_all_backups(
upid: &UPID, upid: &UPID,
ns: BackupNamespace, ns: BackupNamespace,
max_depth: Option<usize>, max_depth: Option<usize>,
owner: Option<Authid>, owner: Option<&Authid>,
filter: Option<&dyn Fn(&BackupManifest) -> bool>, filter: Option<&dyn Fn(&BackupManifest) -> bool>,
) -> Result<Vec<String>, Error> { ) -> Result<Vec<String>, Error> {
let mut errors = Vec::new(); let mut errors = Vec::new();