[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] Fix some logic errors in storage.partitioning.shouldClear.



If we're not clearing any partitions, return early. Also, be more explicit
about the CLEARPART_TYPE_LINUX case.
---
 storage/partitioning.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/storage/partitioning.py b/storage/partitioning.py
index 3046eec..afa4c76 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -253,6 +253,9 @@ def shouldClear(part, clearPartType, clearPartDisks=None, protectedPartitions=No
     if not isinstance(part, PartitionDevice):
         return False
 
+    if clearPartType == CLEARPART_TYPE_NONE:
+        return False
+
     # If we got a list of disks to clear, make sure this one's on it
     if clearPartDisks and part.disk.name not in clearPartDisks:
         return False
@@ -265,7 +268,8 @@ def shouldClear(part, clearPartType, clearPartDisks=None, protectedPartitions=No
     if part.partType not in [parted.PARTITION_NORMAL, parted.PARTITION_LOGICAL]:
         return False
 
-    if clearPartType != CLEARPART_TYPE_ALL and not part.format.linuxNative and \
+    if clearPartType == CLEARPART_TYPE_LINUX and \
+       not part.format.linuxNative and \
        not part.getFlag(parted.PARTITION_LVM) and \
        not part.getFlag(parted.PARTITION_RAID) and \
        not part.getFlag(parted.PARTITION_SWAP):
-- 
1.6.0.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]