Updated handling of removed status for devices without image file support

This commit is contained in:
Uwe Seimet
2021-09-05 16:58:02 +02:00
parent 695a9967b8
commit db6a5a0970

View File

@@ -732,9 +732,13 @@ bool Attach(int fd, const PbDeviceDefinition& pb_device, Device *map[], bool dry
} }
} }
// If no filename was provided the media is considered removed // If no filename was provided the medium is considered removed
if (filename.empty()) { FileSupport *file_support = dynamic_cast<FileSupport *>(device);
device->SetRemoved(true); if (file_support) {
device->SetRemoved(filename.empty());
}
else {
device->SetRemoved(false);
} }
device->SetId(id); device->SetId(id);
@@ -771,8 +775,6 @@ bool Attach(int fd, const PbDeviceDefinition& pb_device, Device *map[], bool dry
} }
} }
FileSupport *file_support = dynamic_cast<FileSupport *>(device);
// File check (type is HD, for removable media drives, CD and MO the medium (=file) may be inserted later) // File check (type is HD, for removable media drives, CD and MO the medium (=file) may be inserted later)
if (file_support && !device->IsRemovable() && filename.empty()) { if (file_support && !device->IsRemovable() && filename.empty()) {
delete device; delete device;