[pbs-devel] [PATCH v2 proxmox-backup 3/3] sync: push: use direct api version comparison in compatibility checks

Christian Ebner c.ebner at proxmox.com
Thu Nov 28 17:07:21 CET 2024


Use the trait implementations of `ApiVersion` to perform operator
based version comparisons. This makes the comparison more readable
and reduces the risk for errors.

No functional change intended.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 1:
- use operator based version comparison, improving code readability

 src/server/push.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/server/push.rs b/src/server/push.rs
index 95c7c6bff..fdd259aff 100644
--- a/src/server/push.rs
+++ b/src/server/push.rs
@@ -129,13 +129,11 @@ impl PushParameters {
         let api_version = ApiVersion::try_from(version_info)?;
 
         // push assumes namespace support on the remote side, fail early if missing
-        if api_version.major < 2 || (api_version.major == 2 && api_version.minor < 2) {
+        if api_version < ApiVersion::new(2, 2, 0) {
             bail!("Unsupported remote api version, minimum v2.2 required");
         }
 
-        let supports_prune_delete_stats = api_version.major > 3
-            || (api_version.major == 3 && api_version.minor >= 3)
-            || (api_version.major == 3 && api_version.minor == 2 && api_version.release >= 11);
+        let supports_prune_delete_stats = api_version >= ApiVersion::new(3, 2, 11);
 
         let target = PushTarget {
             remote,
-- 
2.39.5





More information about the pbs-devel mailing list