[[PATCH rhel7-branch] 2/5] "Delete All" on the reclaim dialog should not delete hdiso source (#980496).

Chris Lumens clumens at redhat.com
Mon Jan 27 15:09:15 UTC 2014


Lots of little pieces to make this one go:

(1) Don't call recursiveDelete on disks.  That's what actually causes the
traceback in the bug report.

(2) Change IMMUTABLE_COL to TYPE_COL so we have a way of telling what's
protected, what's the free space line, etc.

(3) Decide whether the user's asked to reclaim anything by counting up
delete actions, not by size.  This lets us take existing free space into
account.

(4) Give existing free space lines in the store an empty action so
everywhere we do something based on action, those won't be touched.

(5) Stop basing action visibility on whether a device is editable or not.
Always show them, which is why #4 is needed.
---
 pyanaconda/ui/gui/spokes/lib/resize.glade |  6 ++---
 pyanaconda/ui/gui/spokes/lib/resize.py    | 43 +++++++++++++++++++++----------
 2 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/lib/resize.glade b/pyanaconda/ui/gui/spokes/lib/resize.glade
index 73da596..95e824c 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.glade
+++ b/pyanaconda/ui/gui/spokes/lib/resize.glade
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.0 on Wed Jan 22 15:54:55 2014 -->
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
   <object class="GtkTreeStore" id="diskStore">
@@ -15,8 +16,8 @@
       <column type="gchararray"/>
       <!-- column-name diskEditable -->
       <column type="gboolean"/>
-      <!-- column-name diskImmutable -->
-      <column type="gboolean"/>
+      <!-- column-name diskType -->
+      <column type="gint"/>
       <!-- column-name diskTooltip -->
       <column type="gchararray"/>
       <!-- column-name diskResizeTarget -->
@@ -196,7 +197,6 @@
                         <child>
                           <object class="GtkCellRendererText" id="actionRenderer"/>
                           <attributes>
-                            <attribute name="visible">5</attribute>
                             <attribute name="text">4</attribute>
                           </attributes>
                         </child>
diff --git a/pyanaconda/ui/gui/spokes/lib/resize.py b/pyanaconda/ui/gui/spokes/lib/resize.py
index a60d8da..b398eda 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.py
+++ b/pyanaconda/ui/gui/spokes/lib/resize.py
@@ -38,18 +38,23 @@ FILESYSTEM_COL = 2
 RECLAIMABLE_COL = 3
 ACTION_COL = 4
 EDITABLE_COL = 5
-IMMUTABLE_COL = 6
+TYPE_COL = 6
 TOOLTIP_COL = 7
 RESIZE_TARGET_COL = 8
 NAME_COL = 9
 
+TY_NORMAL = 0
+TY_FREE_SPACE = 1
+TY_PROTECTED = 2
+
 PartStoreRow = namedtuple("PartStoreRow", ["id", "desc", "fs", "reclaimable",
-                                           "action", "editable", "immutable",
+                                           "action", "editable", "ty",
                                            "tooltip", "target", "name"])
 
 PRESERVE = N_("Preserve")
 SHRINK = N_("Shrink")
 DELETE = N_("Delete")
+NOTHING = ""
 
 class ResizeDialog(GUIObject):
     builderObjects = ["actionStore", "diskStore", "resizeDialog", "resizeAdjustment"]
@@ -136,7 +141,7 @@ class ResizeDialog(GUIObject):
                                                 "<span foreground='grey' style='italic'>%s total</span>",
                                                 _(PRESERVE),
                                                 editable,
-                                                False,
+                                                TY_NORMAL,
                                                 self._get_tooltip(disk),
                                                 disk.size,
                                                 disk.name])
@@ -158,13 +163,18 @@ class ResizeDialog(GUIObject):
                         freeSize = dev.size
                         resizeString = "<span foreground='grey'>%s</span>" % _("Not resizeable")
 
+                    if dev.protected:
+                        ty = TY_PROTECTED
+                    else:
+                        ty = TY_NORMAL
+
                     self._diskStore.append(itr, [dev.id,
                                                  self._description(dev),
                                                  dev.format.type,
                                                  resizeString,
                                                  _(PRESERVE),
                                                  not dev.protected,
-                                                 False,
+                                                 ty,
                                                  self._get_tooltip(dev),
                                                  dev.size,
                                                  dev.name])
@@ -179,9 +189,9 @@ class ResizeDialog(GUIObject):
                                              _("""<span foreground='grey' style='italic'>Free space</span>"""),
                                              "",
                                              "<span foreground='grey' style='italic'>%s</span>" % size_str(diskFree),
-                                             _(PRESERVE),
+                                             NOTHING,
                                              False,
-                                             True,
+                                             TY_FREE_SPACE,
                                              self._get_tooltip(disk),
                                              float(converted),
                                              ""])
@@ -284,10 +294,10 @@ class ResizeDialog(GUIObject):
         # The reclaim button is sensitive if two conditions are met:
         # (1) There's enough available space (existing free/unpartitioned space,
         #     shrink space, etc.) on all disks.
-        # (2) At least one destructive action has been chosen.  We can detect
-        #     this by checking whether got is non-zero.
+        # (2) At least one destructive action has been chosen.
+        nDeletes = len([row for row in self._diskStore if row[ACTION_COL] == _(DELETE)])
         need = self.payload.spaceRequired
-        self._resizeButton.set_sensitive(got+self._initialFreeSpace >= need and got > Size(0))
+        self._resizeButton.set_sensitive(got+self._initialFreeSpace >= need and nDeletes > 0)
 
     def refresh(self, disks):
         super(ResizeDialog, self).refresh()
@@ -316,10 +326,10 @@ class ResizeDialog(GUIObject):
     def _sumReclaimableSpace(self, model, path, itr, *args):
         obj = PartStoreRow(*model[itr])
 
-        if not obj.editable:
+        device = self.storage.devicetree.getDeviceByID(obj.id)
+        if device.isDisk and device.partitioned:
             return False
 
-        device = self.storage.devicetree.getDeviceByID(obj.id)
         if obj.action == _(PRESERVE):
             return False
         if obj.action == _(SHRINK):
@@ -359,7 +369,7 @@ class ResizeDialog(GUIObject):
                 # the free space lines.  We just want to leave them in the display
                 # for information, but you can't choose to preserve/delete/shrink
                 # them.
-                if self._diskStore[partItr][IMMUTABLE_COL]:
+                if self._diskStore[partItr][TYPE_COL] in [TY_FREE_SPACE, TY_PROTECTED]:
                     partItr = self._diskStore.iter_next(partItr)
                     continue
 
@@ -384,6 +394,11 @@ class ResizeDialog(GUIObject):
         self._update_reclaim_button(Size(spec="%f MB" % self._selectedReclaimableSpace))
         self._update_action_buttons(selectedRow)
 
+    def _recursiveRemove(self, device):
+        children = [d for d in self.storage.devices if device in d.parents and not d.protected]
+        for child in children:
+            self.storage.recursiveRemove(child)
+
     def _scheduleActions(self, model, path, itr, *args):
         obj = PartStoreRow(*model[itr])
         device = self.storage.devicetree.getDeviceByID(obj.id)
@@ -397,9 +412,9 @@ class ResizeDialog(GUIObject):
             if device.resizable:
                 self.storage.resizeDevice(device, obj.target)
             else:
-                self.storage.recursiveRemove(device)
+                self._recursiveRemove(device)
         elif obj.action == _(DELETE):
-            self.storage.recursiveRemove(device)
+            self._recursiveRemove(device)
 
         return False
 
-- 
1.8.3.1



More information about the anaconda-patches mailing list