diff --git a/src/api2/config/changer.rs b/src/api2/config/changer.rs index 1b429659..8404d20b 100644 --- a/src/api2/config/changer.rs +++ b/src/api2/config/changer.rs @@ -59,8 +59,16 @@ pub fn create_changer( check_drive_path(&linux_changers, &path)?; - if config.sections.get(&name).is_some() { - bail!("Entry '{}' already exists", name); + let existing: Vec = config.convert_to_typed_array("changer")?; + + for changer in existing { + if changer.name == name { + bail!("Entry '{}' already exists", name); + } + + if changer.path == path { + bail!("Path '{}' already in use by '{}'", path, changer.name); + } } let item = ScsiTapeChanger { diff --git a/src/api2/config/drive.rs b/src/api2/config/drive.rs index 78ebecb3..7d7803d3 100644 --- a/src/api2/config/drive.rs +++ b/src/api2/config/drive.rs @@ -56,8 +56,15 @@ pub fn create_drive(param: Value) -> Result<(), Error> { check_drive_path(&linux_drives, &item.path)?; - if config.sections.get(&item.name).is_some() { - bail!("Entry '{}' already exists", item.name); + let existing: Vec = config.convert_to_typed_array("linux")?; + + for drive in existing { + if drive.name == item.name { + bail!("Entry '{}' already exists", item.name); + } + if drive.path == item.path { + bail!("Path '{}' already used in drive '{}'", item.path, drive.name); + } } config.set_data(&item.name, "linux", &item)?;