From 43cfb3c35adfa4de0373b7238ba3da5566c16748 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 9 Dec 2020 12:55:54 +0100 Subject: [PATCH] tape: do not remove changer while still used --- src/api2/config/changer.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/api2/config/changer.rs b/src/api2/config/changer.rs index ed4dd788..6501aa23 100644 --- a/src/api2/config/changer.rs +++ b/src/api2/config/changer.rs @@ -11,6 +11,7 @@ use crate::{ LINUX_DRIVE_PATH_SCHEMA, DriveListEntry, ScsiTapeChanger, + LinuxTapeDrive, }, tape::{ linux_tape_changer_list, @@ -216,6 +217,15 @@ pub fn delete_changer(name: String, _param: Value) -> Result<(), Error> { None => bail!("Delete changer '{}' failed - no such entry", name), } + let drive_list: Vec = config.convert_to_typed_array("linux")?; + for drive in drive_list { + if let Some(changer) = drive.changer { + if changer == name { + bail!("Delete changer '{}' failed - used by drive '{}'", name, drive.name); + } + } + } + config::drive::save_config(&config)?; Ok(())