From 5116453b6d6e8c6b38eade9e371c8390f4b27927 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 20 Apr 2022 12:20:28 +0200 Subject: [PATCH] datastore: drop Ord from BackupGroup This one is supposed to be linked to a datastore instance, so it won't be Ord for now. Signed-off-by: Wolfgang Bumiller --- pbs-datastore/src/backup_info.rs | 16 ++++++++-------- src/api2/tape/backup.rs | 2 +- src/backup/verify.rs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pbs-datastore/src/backup_info.rs b/pbs-datastore/src/backup_info.rs index 05532558..8406bc5f 100644 --- a/pbs-datastore/src/backup_info.rs +++ b/pbs-datastore/src/backup_info.rs @@ -8,20 +8,14 @@ use pbs_api_types::{BackupType, GroupFilter, BACKUP_DATE_REGEX, BACKUP_FILE_REGE use super::manifest::MANIFEST_BLOB_NAME; /// BackupGroup is a directory containing a list of BackupDir -#[derive(Debug, Eq, PartialEq, Hash, Clone)] +#[derive(Debug, PartialEq, Hash, Clone)] pub struct BackupGroup { group: pbs_api_types::BackupGroup, } -impl std::cmp::Ord for BackupGroup { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.group.cmp(&other.group) - } -} - impl std::cmp::PartialOrd for BackupGroup { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) + Some(self.group.cmp(&other.group)) } } @@ -32,6 +26,12 @@ impl BackupGroup { } } + /// Access the underlying [`BackupGroup`](pbs_api_types::BackupGroup). + #[inline] + pub fn group(&self) -> &pbs_api_types::BackupGroup { + &self.group + } + pub fn backup_type(&self) -> BackupType { self.group.ty } diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs index 59a3e704..d0ae07a8 100644 --- a/src/api2/tape/backup.rs +++ b/src/api2/tape/backup.rs @@ -410,7 +410,7 @@ fn backup_worker( let mut group_list = datastore.list_backup_groups()?; - group_list.sort_unstable(); + group_list.sort_unstable_by(|a, b| a.group().cmp(b.group())); let (group_list, group_count) = if let Some(group_filters) = &setup.group_filter { let filter_fn = |group: &BackupGroup, group_filters: &[GroupFilter]| { diff --git a/src/backup/verify.rs b/src/backup/verify.rs index 2c618691..b355f151 100644 --- a/src/backup/verify.rs +++ b/src/backup/verify.rs @@ -550,7 +550,7 @@ pub fn verify_all_backups( } }; - list.sort_unstable(); + list.sort_unstable_by(|a, b| a.group().cmp(b.group())); let group_count = list.len(); task_log!(worker, "found {} groups", group_count);