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

[PATCH] Fix action sorting for partitions on the same disk. (#498064)



---
 storage/devicetree.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/storage/devicetree.py b/storage/devicetree.py
index 71df344..318d588 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -526,7 +526,11 @@ class DeviceTree(object):
                 # generally destroy partitions after lvs, vgs, &c
                 elif isinstance(a1.device, PartitionDevice) and \
                      isinstance(a2.device, PartitionDevice):
-                    ret = cmp(a2.device.name, a1.device.name)
+                    if a1.device.disk == a2.device.disk:
+                        ret = cmp(a2.device.partedPartition.number,
+                                  a1.device.partedPartition.number)
+                    else:
+                        ret = cmp(a2.device.name, a1.device.name)
                 elif isinstance(a1.device, PartitionDevice) and \
                      not isinstance(a2.device, DiskDevice):
                     ret = 1
@@ -605,7 +609,11 @@ class DeviceTree(object):
                 # generally create partitions before other device types
                 elif isinstance(a1.device, PartitionDevice) and \
                      isinstance(a2.device, PartitionDevice):
-                    ret = cmp(a1.device.name, a2.device.name)
+                    if a1.device.disk == a2.device.disk:
+                        ret = cmp(a1.device.partedPartition.number,
+                                  a2.device.partedPartition.number)
+                    else:
+                        ret = cmp(a1.device.name, a2.device.name)
                 elif isinstance(a1.device, PartitionDevice) and \
                      not isinstance(a2.device, DiskDevice):
                     ret = -1
-- 
1.6.0.6


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