[mount] Winnow partition list

- Simplify the iteration by first determining which partitions
   are mountable (at all).
 - This guards against the very rare case that a partition
   does not have a mountPoint at all (the if guarded against that)
   where the lambda passed to sort() would get a KeyError.
This commit is contained in:
Adriaan de Groot 2019-08-19 06:28:32 -04:00
parent 8aedd8b175
commit 395c375c60

View File

@ -155,11 +155,9 @@ def run():
# This way, we ensure / is mounted before the rest, and every mount point
# is created on the right partition (e.g. if a partition is to be mounted
# under /tmp, we make sure /tmp is mounted before the partition)
partitions.extend(extra_mounts)
partitions.sort(key=lambda x: x["mountPoint"])
for partition in partitions:
if "mountPoint" not in partition or not partition["mountPoint"]:
continue
mountable_partitions = [ p for p in partitions + extra_mounts if "mountPoint" in p and p["mountPoint"] ]
mountable_partitions.sort(key=lambda x: x["mountPoint"])
for partition in mountable_partitions:
mount_partition(root_mount_point, partition, partitions)
libcalamares.globalstorage.insert("rootMountPoint", root_mount_point)