[pbs-devel] [PATCH proxmox-backup v2 4/6] api: admin: datastore: factor out 'get_group_owner'
Dominik Csapak
d.csapak at proxmox.com
Wed Oct 8 15:43:34 CEST 2025
and change the `eprintln` to a `log::warn`
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
no changes in v2
src/api2/admin/datastore.rs | 47 +++++++++++++++++++------------------
1 file changed, 24 insertions(+), 23 deletions(-)
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index 26799de6e..0b133d166 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -160,18 +160,8 @@ fn backup_group_to_group_list_item(
auth_id: &Authid,
list_all: bool,
) -> Option<GroupListItem> {
- let owner = match datastore.get_owner(ns, group.as_ref()) {
- Ok(auth_id) => auth_id,
- Err(err) => {
- eprintln!(
- "Failed to get owner of group '{}' in {} - {}",
- group.group(),
- print_store_and_ns(datastore.name(), ns),
- err
- );
- return None;
- }
- };
+ let owner = get_group_owner(datastore.name(), ns, &group)?;
+
if !list_all && check_backup_owner(&owner, auth_id).is_err() {
return None;
}
@@ -439,6 +429,25 @@ pub async fn list_snapshots(
.map_err(|err| format_err!("failed to await blocking task: {err}"))?
}
+fn get_group_owner(
+ store: &str,
+ ns: &BackupNamespace,
+ group: &pbs_datastore::BackupGroup,
+) -> Option<Authid> {
+ match group.get_owner() {
+ Ok(auth_id) => Some(auth_id),
+ Err(err) => {
+ log::warn!(
+ "Failed to get owner of group '{}' in {} - {}",
+ group.group(),
+ print_store_and_ns(store, ns),
+ err
+ );
+ None
+ }
+ }
+}
+
/// This must not run in a main worker thread as it potentially does tons of I/O.
unsafe fn list_snapshots_blocking(
store: String,
@@ -482,17 +491,9 @@ unsafe fn list_snapshots_blocking(
};
groups.iter().try_fold(Vec::new(), |mut snapshots, group| {
- let owner = match group.get_owner() {
- Ok(auth_id) => auth_id,
- Err(err) => {
- eprintln!(
- "Failed to get owner of group '{}' in {} - {}",
- group.group(),
- print_store_and_ns(&store, &ns),
- err
- );
- return Ok(snapshots);
- }
+ let owner = match get_group_owner(&store, &ns, group) {
+ Some(auth_id) => auth_id,
+ None => return Ok(snapshots),
};
if !list_all && check_backup_owner(&owner, &auth_id).is_err() {
--
2.47.3
More information about the pbs-devel
mailing list