]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/tape/inventory.rs
typo fixes all over the place
[proxmox-backup.git] / src / tape / inventory.rs
index 963eac5822b0d63eb185a90aac617b9cc51bc171..7ae9d56504d8d6df32e02f9e6225379a904cbc51 100644 (file)
@@ -230,6 +230,11 @@ impl Inventory {
         self.map.get(uuid).map(|entry| &entry.id)
     }
 
+    /// List all media Uuids
+    pub fn media_list(&self) -> Vec<&Uuid> {
+        self.map.keys().collect()
+    }
+
     /// find media by label_text
     pub fn find_media_by_label_text(&self, label_text: &str) -> Option<&MediaId> {
         self.map.values().find_map(|entry| {
@@ -271,7 +276,7 @@ impl Inventory {
                         continue; // belong to another pool
                     }
 
-                    if set.uuid.as_ref() == [0u8;16] { // should we do this??
+                    if set.uuid.as_ref() == [0u8;16] {
                         list.push(MediaId {
                             label: entry.id.label.clone(),
                             media_set_label: None,
@@ -500,20 +505,27 @@ impl Inventory {
             Some(time) => time,
         };
 
-        let max_use_time = match media_set_policy {
-            MediaSetPolicy::ContinueCurrent => {
-                match self.media_set_next_start_time(&set.uuid) {
-                    Some(next_start_time) => next_start_time,
-                    None => return i64::MAX,
-                }
-            }
-            MediaSetPolicy::AlwaysCreate => {
-                set_start_time + 1
+        let max_use_time = match self.media_set_next_start_time(&set.uuid) {
+            Some(next_start_time) => {
+               match media_set_policy {
+                   MediaSetPolicy::AlwaysCreate => set_start_time,
+                   _ => next_start_time,
+               }
             }
-            MediaSetPolicy::CreateAt(ref event) => {
-                match compute_next_event(event, set_start_time, false) {
-                    Ok(Some(next)) => next,
-                    Ok(None) | Err(_) => return i64::MAX,
+            None => {
+                match media_set_policy {
+                    MediaSetPolicy::ContinueCurrent => {
+                        return i64::MAX;
+                    }
+                    MediaSetPolicy::AlwaysCreate => {
+                        set_start_time
+                    }
+                    MediaSetPolicy::CreateAt(ref event) => {
+                        match compute_next_event(event, set_start_time, false) {
+                            Ok(Some(next)) => next,
+                            Ok(None) | Err(_) => return i64::MAX,
+                        }
+                    }
                 }
             }
         };
@@ -549,7 +561,7 @@ impl Inventory {
 
     // Helpers to simplify testing
 
-    /// Genreate and insert a new free tape (test helper)
+    /// Generate and insert a new free tape (test helper)
     pub fn generate_free_tape(&mut self, label_text: &str, ctime: i64) -> Uuid {
 
         let label = MediaLabel {
@@ -564,7 +576,7 @@ impl Inventory {
         uuid
     }
 
-    /// Genreate and insert a new tape assigned to a specific pool
+    /// Generate and insert a new tape assigned to a specific pool
     /// (test helper)
     pub fn generate_assigned_tape(
         &mut self,
@@ -588,7 +600,7 @@ impl Inventory {
         uuid
     }
 
-    /// Genreate and insert a used tape (test helper)
+    /// Generate and insert a used tape (test helper)
     pub fn generate_used_tape(
         &mut self,
         label_text: &str,
@@ -654,6 +666,11 @@ impl Inventory {
         self.set_media_status(uuid, Some(MediaStatus::Damaged))
     }
 
+    /// Lock database, reload database, set status to Retired, store database
+    pub fn set_media_status_retired(&mut self, uuid: &Uuid) -> Result<(), Error> {
+        self.set_media_status(uuid, Some(MediaStatus::Retired))
+    }
+
     /// Lock database, reload database, set status to None, store database
     pub fn clear_media_status(&mut self, uuid: &Uuid) -> Result<(), Error> {
         self.set_media_status(uuid, None)