[master 1/1] Fix bad space needed messages

jkonecny12 installerbot-noreply at redhat.com
Tue Nov 3 16:20:16 UTC 2015


From: Jiri Konecny <jkonecny at redhat.com>

When we reduce metadata from device size in space check we also
need to tell user how much space he needs on root to get installation
done. That means we need to add metadata in count when calculating this
space deficit.
---
 pyanaconda/packaging/dnfpayload.py     | 17 ++++++++++++++++-
 pyanaconda/ui/gui/spokes/lib/resize.py |  7 +++++--
 pyanaconda/ui/lib/space.py             |  6 ++++--
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py
index 820f20c..99b93db 100644
--- a/pyanaconda/packaging/dnfpayload.py
+++ b/pyanaconda/packaging/dnfpayload.py
@@ -1,7 +1,7 @@
 # dnfpayload.py
 # DNF/rpm software payload management.
 #
-# Copyright (C) 2013  Red Hat, Inc.
+# Copyright (C) 2013-2015  Red Hat, Inc.
 #
 # This copyrighted material is made available to anyone wishing to use,
 # modify, copy, or redistribute it subject to the terms and conditions of
@@ -18,6 +18,7 @@
 # Red Hat, Inc.
 #
 # Red Hat Author(s): Ales Kozumplik <akozumpl at redhat.com>
+#                    Jiri Konecny   <jkonecny at redhat.com>
 #
 import os
 
@@ -595,6 +596,20 @@ def _spaceRequired(self):
         log.debug("Total size required %s", total_space)
         return total_space
 
+    def requiredDeviceSize(self, format_class):
+        """ We need to provide information how big device is required to have successful
+            installation. ``format_class`` should be filesystem format
+            class for the **root** filesystem this class carry information about
+            metadata size.
+
+            :param format_class: Class of the filesystem format.
+            :type format_class: Class which inherits :class:`blivet.formats.fs.FS`
+            :returns: Size of the device with given filesystem format.
+            :rtype: :class:`blivet.size.Size`
+        """
+        device_size = format_class.getRequiredSize(self.spaceRequired)
+        return device_size.roundToNearest(Size("1 MiB"))
+
     def _isGroupVisible(self, grpid):
         grp = self._base.comps.group_by_pattern(grpid)
         if grp is None:
diff --git a/pyanaconda/ui/gui/spokes/lib/resize.py b/pyanaconda/ui/gui/spokes/lib/resize.py
index cc086f9..22f2161 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.py
+++ b/pyanaconda/ui/gui/spokes/lib/resize.py
@@ -32,6 +32,7 @@
 from pyanaconda.ui.gui import GUIObject
 from pyanaconda.ui.gui.utils import blockedHandler, escape_markup, timed_action
 from blivet.size import Size
+from blivet.formats.fs import FS
 
 __all__ = ["ResizeDialog"]
 
@@ -84,7 +85,8 @@ def __init__(self, data, storage, payload):
 
         self._required_label = self.builder.get_object("requiredSpaceLabel")
         markup = self._required_label.get_label()
-        self._required_label.set_markup(markup % escape_markup(str(self.payload.spaceRequired)))
+        required_dev_size = self.payload.requiredDeviceSize(FS.biggestOverheadFS())
+        self._required_label.set_markup(markup % escape_markup(str(required_dev_size)))
 
         self._reclaimDescLabel = self.builder.get_object("reclaimDescLabel")
 
@@ -314,7 +316,8 @@ def _update_action_buttons(self, row):
             self._deleteButton.set_sensitive(False)
 
     def _update_reclaim_button(self, got):
-        self._resizeButton.set_sensitive(got+self._initialFreeSpace >= self.payload.spaceRequired)
+        required_dev_size = self.payload.requiredDeviceSize(FS.biggestOverheadFS())
+        self._resizeButton.set_sensitive(got+self._initialFreeSpace >= required_dev_size)
 
     # pylint: disable=arguments-differ
     def refresh(self, disks):
diff --git a/pyanaconda/ui/lib/space.py b/pyanaconda/ui/lib/space.py
index 067e4d8..3dba7b4 100644
--- a/pyanaconda/ui/lib/space.py
+++ b/pyanaconda/ui/lib/space.py
@@ -77,7 +77,8 @@ def check(self):
         log.info("fs space: %s  needed: %s", free, needed)
         self.success = (free > needed)
         if not self.success:
-            self.deficit = needed - free
+            dev_required_size = self.payload.requiredDeviceSize(self.storage.rootDevice.format)
+            self.deficit = dev_required_size - self.storage.rootDevice.size
             self.error_message = _(self.error_template) % self.deficit
 
         return self.success
@@ -108,7 +109,8 @@ def check(self):
         log.info("fs space: %s  needed: %s", free, needed)
         self.success = (free > needed)
         if not self.success:
-            self.deficit = needed - free
+            dev_required_size = self.payload.requiredDeviceSize(self.storage.rootDevice.format)
+            self.deficit = dev_required_size - self.storage.rootDevice.size
             self.error_message = _(self.error_template) % self.deficit
 
         return self.success


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/812d354ea61bc10738835bf6c6021687e1af1150


More information about the anaconda-patches mailing list