In case all IDs are reserved recommend 0

Otherwise the occupied list is empty and this exception brings down the
whole web interface.

This can be easily provoked by just reserving all IDs in the web interface.
This commit is contained in:
Phil Eichinger 2022-06-30 23:17:55 +02:00
parent 348b5dd026
commit a33a228b6b
1 changed files with 4 additions and 1 deletions

View File

@ -32,7 +32,10 @@ def get_valid_scsi_ids(devices, reserved_ids):
if unoccupied_ids:
recommended_id = unoccupied_ids[-1]
else:
recommended_id = occupied_ids.pop(0)
if occupied_ids:
recommended_id = occupied_ids.pop(0)
else:
recommended_id = 0
return valid_ids, recommended_id