tape: media catalog: use match for magic check

like in other parts of the code

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2022-05-11 14:57:52 +02:00 committed by Dominik Csapak
parent 707c48ad46
commit e49bd1e98f
2 changed files with 18 additions and 15 deletions

View File

@ -10,9 +10,9 @@ use proxmox_schema::api;
use proxmox_sys::{task_log, task_warn, WorkerTaskContext};
use pbs_api_types::{
Authid, BackupNamespace, GroupFilter, MediaPoolConfig, Operation, TapeBackupJobConfig,
TapeBackupJobSetup, TapeBackupJobStatus, Userid, JOB_ID_SCHEMA, PRIV_DATASTORE_READ,
PRIV_TAPE_AUDIT, PRIV_TAPE_WRITE, UPID_SCHEMA,
Authid, GroupFilter, MediaPoolConfig, Operation, TapeBackupJobConfig, TapeBackupJobSetup,
TapeBackupJobStatus, Userid, JOB_ID_SCHEMA, PRIV_DATASTORE_READ, PRIV_TAPE_AUDIT,
PRIV_TAPE_WRITE, UPID_SCHEMA,
};
use pbs_config::CachedUserInfo;

View File

@ -742,12 +742,13 @@ impl MediaCatalog {
return Ok((false, None, None));
}
if magic == Self::PROXMOX_BACKUP_MEDIA_CATALOG_MAGIC_1_0 {
// only use in unreleased versions
bail!("old catalog format (v1.0) is no longer supported");
match magic {
// only used in unreleased versions
Self::PROXMOX_BACKUP_MEDIA_CATALOG_MAGIC_1_0 => {
bail!("old catalog format (v1.0) is no longer supported")
}
if magic != Self::PROXMOX_BACKUP_MEDIA_CATALOG_MAGIC_1_1 {
bail!("wrong magic number");
Self::PROXMOX_BACKUP_MEDIA_CATALOG_MAGIC_1_1 => {}
_ => bail!("wrong magic number"),
}
let mut entry_type = [0u8; 1];
@ -800,12 +801,14 @@ impl MediaCatalog {
Ok(true) => { /* OK */ }
Err(err) => bail!("read failed - {}", err),
}
if magic == Self::PROXMOX_BACKUP_MEDIA_CATALOG_MAGIC_1_0 {
// only use in unreleased versions
bail!("old catalog format (v1.0) is no longer supported");
match magic {
// only used in unreleased versions
Self::PROXMOX_BACKUP_MEDIA_CATALOG_MAGIC_1_0 => {
bail!("old catalog format (v1.0) is no longer supported")
}
if magic != Self::PROXMOX_BACKUP_MEDIA_CATALOG_MAGIC_1_1 {
bail!("wrong magic number");
Self::PROXMOX_BACKUP_MEDIA_CATALOG_MAGIC_1_1 => {}
_ => bail!("wrong magic number"),
}
found_magic_number = true;
continue;