tape: do not use drive.open() within pmt

Do not fail if no media is loaded. Inportant for load command.
This commit is contained in:
Dietmar Maurer 2021-02-01 12:39:50 +01:00
parent 90769e5694
commit 19e4a36c70

View File

@ -66,7 +66,7 @@ fn get_tape_handle(param: &Value) -> Result<LinuxTapeHandle, Error> {
let (config, _digest) = config::drive::config()?;
let drive: LinuxTapeDrive = config.lookup("linux", &name)?;
eprintln!("using device {}", drive.path);
return drive.open();
return Ok(LinuxTapeHandle::new(open_linux_tape_device(&drive.path)?))
}
if let Some(device) = param["device"].as_str() {
@ -78,7 +78,7 @@ fn get_tape_handle(param: &Value) -> Result<LinuxTapeHandle, Error> {
let (config, _digest) = config::drive::config()?;
let drive: LinuxTapeDrive = config.lookup("linux", &name)?;
eprintln!("using device {}", drive.path);
return drive.open();
return Ok(LinuxTapeHandle::new(open_linux_tape_device(&drive.path)?))
}
if let Ok(device) = std::env::var("TAPE") {
@ -98,7 +98,7 @@ fn get_tape_handle(param: &Value) -> Result<LinuxTapeHandle, Error> {
let name = drive_names[0];
let drive: LinuxTapeDrive = config.lookup("linux", &name)?;
eprintln!("using device {}", drive.path);
return drive.open();
return Ok(LinuxTapeHandle::new(open_linux_tape_device(&drive.path)?))
}
bail!("no drive/device specified");