[PATCH 2/2] Don't allow creating filesystems with a duplicate mountpoint (#851200).

Chris Lumens clumens at redhat.com
Thu Aug 23 15:53:48 UTC 2012


---
 pyanaconda/ui/gui/spokes/custom.glade |  1 -
 pyanaconda/ui/gui/spokes/custom.py    | 22 ++++++++++++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.glade b/pyanaconda/ui/gui/spokes/custom.glade
index b417920..bcca53d 100644
--- a/pyanaconda/ui/gui/spokes/custom.glade
+++ b/pyanaconda/ui/gui/spokes/custom.glade
@@ -146,7 +146,6 @@ after creating the mount point below.</property>
             <child>
               <object class="GtkBox" id="addLabelWarningBox">
                 <property name="can_focus">False</property>
-                <property name="no_show_all">True</property>
                 <property name="valign">start</property>
                 <property name="spacing">6</property>
                 <child>
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 6f5fdcc..87c5254 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -17,6 +17,7 @@
 # Red Hat, Inc.
 #
 # Red Hat Author(s): Chris Lumens <clumens at redhat.com>
+#                    Dave Lehman <dlehman at redhat.com>
 #
 
 # TODO:
@@ -86,16 +87,28 @@ class AddDialog(GUIObject):
     uiFile = "spokes/custom.glade"
 
     def __init__(self, *args, **kwargs):
+        self._existingMountpoints = kwargs.pop("existingMountpoints", [])
         GUIObject.__init__(self, *args, **kwargs)
         self.size = Size(bytes=0)
         self.mountpoint = ""
 
+        self._error = False
+
     def on_add_cancel_clicked(self, button, *args):
+        self._error = False
         self.window.destroy()
 
     def on_add_confirm_clicked(self, button, *args):
         self.mountpoint = self.builder.get_object("addMountPointEntry").get_text()
 
+        if self.mountpoint in self._existingMountpoints:
+            self._warningBox.show_all()
+            self._error = True
+            return
+        else:
+            self._warningBox.hide()
+            self._error = False
+
         size_text = self.builder.get_object("sizeEntry").get_text()
         try:
             self.size = Size(spec=size_text)
@@ -106,9 +119,14 @@ class AddDialog(GUIObject):
 
     def refresh(self):
         GUIObject.refresh(self)
+        self._warningBox = self.builder.get_object("addLabelWarningBox")
+        self._warningBox.hide()
 
     def run(self):
-        return self.window.run()
+        while True:
+            rc = self.window.run()
+            if not self._error:
+                return rc
 
 class ConfirmDeleteDialog(GUIObject):
     builderObjects = ["confirmDeleteDialog"]
@@ -744,7 +762,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
     def on_add_clicked(self, button):
         self._save_right_side(self._current_selector)
 
-        dialog = AddDialog(self.data)
+        dialog = AddDialog(self.data, existingMountpoints=self._accordion.currentPage().mountpoints)
         with enlightbox(self.window, dialog.window):
             dialog.refresh()
             rc = dialog.run()
-- 
1.7.11.2



More information about the anaconda-patches mailing list