[PATCH 2/2] Remove devices in leaves first order (#496630)

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

 



---
 partIntfHelpers.py |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/partIntfHelpers.py b/partIntfHelpers.py
index bd1ddbb..6d91bad 100644
--- a/partIntfHelpers.py
+++ b/partIntfHelpers.py
@@ -133,8 +133,12 @@ def doDeleteDevice(intf, storage, device, confirm=1, quiet=0):
     if confirm and not confirmDelete(intf, device):
         return False
 
-    for dep in storage.deviceDeps(device):
-        storage.destroyDevice(dep)
+    deps = storage.deviceDeps(device)
+    while deps:
+        leaves = [d for d in deps if d.isleaf]
+        for leaf in leaves:
+            storage.destroyDevice(leaf)
+            deps.remove(leaf)
 
     storage.destroyDevice(device)
     return True
@@ -157,12 +161,14 @@ def doDeleteDependentDevices(intf, storage, device, confirm=1, quiet=0):
         return False
 
     immutable = []
-    for dep in deps:
-        if storage.deviceImmutable(dep):
-            immutable.append(dep.path)
-            continue
-        else:
-            storage.destroyDevice(dep)
+    while deps:
+        leaves = [d for d in deps if d.isleaf]
+        for leaf in leaves:
+            if storage.deviceImmutable(leaf):
+                immutable.append(leaf.path)
+            else:
+                storage.destroyDevice(leaf)
+            deps.remove(leaf)
 
     if immutable and not quiet:
         remaining = "\t" + "\n\t".join(immutable) + "\n"
-- 
1.6.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux