Re: [PATCH 5/9] Correct bounds checking problems in 'Shrink current system'

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

 



On 03/29/2009 11:27 PM, Radek Vykydal wrote:
David Cantrell wrote:
The 'Shrink current system' dialog had some bounds checking problems.
Users could enter a size that was too small or too large.

Renamed the function and related controls to use 'shrink' instead of
'resize' in the name to better reflect what the code does.

Use the format's size to set the bounds rather than the partition's.
Since we are shrinking here, we only want to let users select a size
smaller than the current format size.

A size smaller than the minimum will automatically be set to the correct
minimum. Likewise, a size larger than the maximum will automatically be
set to the correct maximum.
---
iw/autopart_type.py | 26 ++++++++++++--------------
ui/autopart.glade | 20 ++++++++++----------
2 files changed, 22 insertions(+), 24 deletions(-)

Looks good, with one possible overlooking - see below?

diff --git a/iw/autopart_type.py b/iw/autopart_type.py
index 6bbca11..106005a 100644
--- a/iw/autopart_type.py
+++ b/iw/autopart_type.py
@@ -37,42 +37,40 @@ from storage.deviceaction import *
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)

-def whichToResize(storage, intf):
+def whichToShrink(storage, intf):
def getActive(combo):
act = combo.get_active_iter()
return combo.get_model().get_value(act, 1)

- def comboCB(combo, resizeSB):
+ def comboCB(combo, shrinkSB):
# partition to resize changed, let's update our spinbutton
+ newSize = shrinkSB.get_value_as_int()
+
part = getActive(combo)
- reqlower = part.minSize
- requpper = part.maxSize
+ reqlower = long(math.ceil(part.format.minSize))
+ requpper = long(math.ceil(part.format.currentSize))

I am not sure, perhaps it is OK, but just in case it was overlooking,
don't we want math.floor for requpper?

You're right.  Made that change and pushed the patch with math.floor.



- adj = resizeSB.get_adjustment()
+ adj = shrinkSB.get_adjustment()
adj.lower = reqlower
adj.upper = requpper
- adj.value = reqlower
adj.set_value(reqlower)


- (dxml, dialog) = gui.getGladeWidget("autopart.glade", "resizeDialog")
+ (dxml, dialog) = gui.getGladeWidget("autopart.glade", "shrinkDialog")

store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
- combo = dxml.get_widget("resizePartCombo")
+ combo = dxml.get_widget("shrinkPartCombo")
combo.set_model(store)
crt = gtk.CellRendererText()
combo.pack_start(crt, True)
combo.set_attributes(crt, text = 0)
- combo.connect("changed", comboCB, dxml.get_widget("resizeSB"))
+ combo.connect("changed", comboCB, dxml.get_widget("shrinkSB"))

biggest = -1
for part in storage.partitions:
if not part.exists:
continue

- # Resize the following storage types:
- # resizable filesystem (e.g., ext3 or ntfs) on resizable partition
- # resizable filesystem on a resizable logical volume
entry = None
if part.resizable and part.format.resizable:
entry = ("%s (%s, %d MB)" % (part.name,
@@ -115,7 +113,7 @@ def whichToResize(storage, intf):
return (rc, [])

request = getActive(combo)
- newSize = dxml.get_widget("resizeSB").get_value_as_int()
+ newSize = dxml.get_widget("shrinkSB").get_value_as_int()
actions = []

try:
@@ -159,7 +157,7 @@ class PartitionTypeWindow(InstallWindow):
self.dispatch.skipStep("bootloader", skip = 0)
else:
if val == -2:
- (rc, actions) = whichToResize(self.storage, self.intf)
+ (rc, actions) = whichToShrink(self.storage, self.intf)
if rc == gtk.RESPONSE_OK:
for action in actions:
self.storage.devicetree.registerAction(action)
diff --git a/ui/autopart.glade b/ui/autopart.glade
index 3335274..52bcb9c 100644
--- a/ui/autopart.glade
+++ b/ui/autopart.glade
@@ -338,10 +338,10 @@
</child>
</widget>

-<widget class="GtkDialog" id="resizeDialog">
+<widget class="GtkDialog" id="shrinkDialog">
<property name="border_width">12</property>
<property name="visible">True</property>
- <property name="title" translatable="yes">Volume to Resize</property>
+ <property name="title" translatable="yes">Volume to Shrink</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
@@ -427,7 +427,7 @@
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
- <property name="label" translatable="yes">_Resize</property>
+ <property name="label" translatable="yes">_Shrink</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -472,7 +472,7 @@
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
- <property name="label" translatable="yes">Which partition would you
like to resize to make room for your installation?</property>
+ <property name="label" translatable="yes">Which partition would you
like to shrink to make room for your installation?</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -495,7 +495,7 @@
</child>

<child>
- <widget class="GtkComboBox" id="resizePartCombo">
+ <widget class="GtkComboBox" id="shrinkPartCombo">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
@@ -517,7 +517,7 @@
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
- <property name="label" translatable="yes">&lt;b&gt;Resize _target
(in MB):&lt;/b&gt;</property>
+ <property name="label" translatable="yes">&lt;b&gt;Shrink _target
(in MB):&lt;/b&gt;</property>
<property name="use_underline">True</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -527,7 +527,7 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="mnemonic_widget">resizeSB</property>
+ <property name="mnemonic_widget">shrinkSB</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
@@ -541,16 +541,16 @@
</child>

<child>
- <widget class="GtkSpinButton" id="resizeSB">
+ <widget class="GtkSpinButton" id="shrinkSB">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">True</property>
- <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+ <property name="update_policy">GTK_UPDATE_IF_VALID</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
- <property name="adjustment">1 0 100 1 10 10</property>
+ <property name="adjustment">1 0 100 1 1 0</property>
</widget>
<packing>
<property name="padding">0</property>

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


--
David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

_______________________________________________
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