[pbs-devel] [PATCH proxmox-backup 1/2] tape: refactor uuid of empty media set into constant

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Nov 29 13:03:32 CET 2022


Am 29/11/2022 um 11:51 schrieb Dominik Csapak:
> so that we have a easily recognizable name for it and can see
> instantly what it does
> 
> make the 'let is_empty' unnecessary as it's clear now what the check is
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/api2/tape/drive.rs |  8 ++++----
>  src/api2/tape/media.rs |  5 ++---
>  src/tape/inventory.rs  | 16 +++++++++-------
>  src/tape/media_pool.rs |  4 ++--
>  4 files changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs
> index 107bcfd8..4bb9ade9 100644
> --- a/src/api2/tape/drive.rs
> +++ b/src/api2/tape/drive.rs
> @@ -42,7 +42,7 @@ use crate::{
>          },
>          file_formats::{MediaLabel, MediaSetLabel},
>          lock_media_pool, lock_media_set, lock_unassigned_media_pool, Inventory, MediaCatalog,
> -        MediaId, TAPE_STATUS_DIR,
> +        MediaId, EMPTY_MEDIA_SET_UUID, TAPE_STATUS_DIR,
>      },
>  };
>  
> @@ -528,7 +528,7 @@ fn write_media_label(
>              label.label_text,
>              pool
>          );
> -        let set = MediaSetLabel::with_data(pool, [0u8; 16].into(), 0, label.ctime, None);
> +        let set = MediaSetLabel::with_data(pool, EMPTY_MEDIA_SET_UUID.into(), 0, label.ctime, None);
>  
>          drive.write_media_set_label(&set, None)?;
>  
> @@ -575,7 +575,7 @@ fn write_media_label(
>              if let Some(ref pool) = pool {
>                  match info.media_set_label {
>                      Some(set) => {
> -                        if set.uuid != [0u8; 16].into() {
> +                        if set.uuid != EMPTY_MEDIA_SET_UUID.into() {

Did not looked to closely, but why not impl a method on MediaSetLabel instead,
avoiding leaking out of that internal detail in the first place?





More information about the pbs-devel mailing list