From 395c375c603f401e4c0ac780fb243c39b1b3c990 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 19 Aug 2019 06:28:32 -0400 Subject: [PATCH] [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. --- src/modules/mount/main.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/modules/mount/main.py b/src/modules/mount/main.py index 1c684c43f..d33b4681b 100644 --- a/src/modules/mount/main.py +++ b/src/modules/mount/main.py @@ -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)