mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-08-15 06:45:27 +00:00
tape: fix 'eject-before-unload' api type
by converting the bool into an option, otherwise having the options not
set at all will fail the unload while deserializing with
'eject-before-unload is not optional'
Also if we can automatically decide this in the future, we can now
detect if the option was explicitely set or not.
Fixes: 66402cdc
("fix #4904: tape changer: add option to eject before unload")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
66402cdc1b
commit
667ec4a3c2
@ -39,18 +39,21 @@ Import/Export, i.e. any media in those slots are considered to be
|
|||||||
.format(&ApiStringFormat::PropertyString(&SLOT_ARRAY_SCHEMA))
|
.format(&ApiStringFormat::PropertyString(&SLOT_ARRAY_SCHEMA))
|
||||||
.schema();
|
.schema();
|
||||||
|
|
||||||
fn is_false(b: &bool) -> bool {
|
#[api(
|
||||||
!b
|
properties: {
|
||||||
}
|
"eject-before-unload": {
|
||||||
|
optional: true,
|
||||||
#[api]
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)]
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
/// Options for Changers
|
/// Options for Changers
|
||||||
pub struct ChangerOptions {
|
pub struct ChangerOptions {
|
||||||
#[serde(default, skip_serializing_if = "is_false")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
/// if set to true, tapes are ejected manually before unloading
|
/// if set to true, tapes are ejected manually before unloading
|
||||||
pub eject_before_unload: bool,
|
pub eject_before_unload: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const CHANGER_OPTIONS_STRING_SCHEMA: Schema = StringSchema::new("Changer options")
|
pub const CHANGER_OPTIONS_STRING_SCHEMA: Schema = StringSchema::new("Changer options")
|
||||||
|
@ -433,7 +433,7 @@ impl MediaChange for MtxMediaChanger {
|
|||||||
.parse_property_string(self.config.options.as_deref().unwrap_or_default())?,
|
.parse_property_string(self.config.options.as_deref().unwrap_or_default())?,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if options.eject_before_unload {
|
if options.eject_before_unload.unwrap_or(false) {
|
||||||
let file = open_lto_tape_device(&self.drive.path)?;
|
let file = open_lto_tape_device(&self.drive.path)?;
|
||||||
let mut handle = LtoTapeHandle::new(file)?;
|
let mut handle = LtoTapeHandle::new(file)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user