Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-09-04 17:03:52 +0200
committerAnton Hvornum <anton@hvornum.se>2021-09-04 17:03:52 +0200
commit429006fe4b2775d4f28cfaa4ad86028fac56dccd (patch)
tree639db130e6770edb62df77e2ce0bd3e3d26ab3fe
parent1814a19d6adb3e465df2a276cc87f85974f613c3 (diff)
Simplified lambda and made it filter out non relevant disks for the selection process.
-rw-r--r--archinstall/lib/disk.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index 4a5b2f4c..bac46c3a 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -75,6 +75,11 @@ def sort_block_devices_based_on_performance(block_devices):
return result
+def filter_disks_below_size_in_gb(devices, gigabytes):
+ for disk in devices:
+ if disk.size >= gigabytes:
+ yield disk
+
def select_largest_device(devices, gigabytes, filter_out=None):
if not filter_out:
filter_out = []
@@ -84,10 +89,12 @@ def select_largest_device(devices, gigabytes, filter_out=None):
if filter_device in copy_devices:
copy_devices.pop(copy_devices.index(filter_device))
+ copy_devices = list(filter_disks_below_size_in_gb(copy_devices, gigabytes))
+
if not len(copy_devices):
return None
- return max(copy_devices, key=(lambda device : device.size if device.size > gigabytes else 0))
+ return max(copy_devices, key=(lambda device : device.size))
def select_disk_larger_than_or_close_to(devices, gigabytes, filter_out=None):
if not filter_out: