]> git.proxmox.com Git - proxmox-backup.git/commitdiff
cleanup rrd bounds checks in datastore status call
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 24 Nov 2022 12:55:22 +0000 (13:55 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 24 Nov 2022 12:55:22 +0000 (13:55 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/api2/status.rs

index 87450d6321b2f269704d45d15790347599292446..ff7d4cbdde706dc6563904bdb9a045f366399404 100644 (file)
@@ -102,10 +102,10 @@ pub async fn datastore_status(
                     }
                 };
 
-                let total = if idx < avail.data.len() && avail.data[idx].is_some() {
-                    avail.data[idx].unwrap() + used
-                } else if idx < total_entry.data.len() && total_entry.data[idx].is_some() {
-                    total_entry.data[idx].unwrap()
+                let total = if let Some(avail) = avail.get(idx) {
+                    avail + used
+                } else if let Some(total) = total_entry.get(idx) {
+                    total
                 } else {
                     history.push(None);
                     continue;