Re: [PATCH rhel6-branch master 1/2] Enforce the same logic on autopart shrink as on resize (#608172)

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

 



On Fri, 2010-07-09 at 17:28 -0700, Brian C. Lane wrote:
> The shrink dialog is presenting different values than resize in the
> partition editor. Use the same logic for both. As a result, it won't
> allow you to shrink a partition if it cannot find its proper minimum
> size.

Looks good, although with some slightly strange whitespace usage (spaces
in parens when defining/calling getResizeMinMax, no space on RHS of
equals sign in innermost assignment to requpper).

Dave

> 
> Related: rhbz#608172
> ---
>  iw/autopart_type.py            |    3 +--
>  iw/partition_ui_helpers_gui.py |   27 +++++++++++++++++----------
>  2 files changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/iw/autopart_type.py b/iw/autopart_type.py
> index 7436751..36d4e6c 100644
> --- a/iw/autopart_type.py
> +++ b/iw/autopart_type.py
> @@ -45,8 +45,7 @@ def whichToShrink(storage, intf):
>          newSize = shrinkSB.get_value_as_int()
>  
>          part = getActive(combo)
> -        reqlower = long(math.ceil(part.format.minSize))
> -        requpper = long(math.floor(part.format.currentSize))
> +        (reqlower, requpper) = getResizeMinMax( part )
>  
>          adj = shrinkSB.get_adjustment()
>          adj.lower = max(1,reqlower)
> diff --git a/iw/partition_ui_helpers_gui.py b/iw/partition_ui_helpers_gui.py
> index 8fa5f6f..34e4524 100644
> --- a/iw/partition_ui_helpers_gui.py
> +++ b/iw/partition_ui_helpers_gui.py
> @@ -26,6 +26,7 @@ import gtk
>  import checklist
>  import datacombo
>  import iutil
> +import math
>  
>  from constants import *
>  from partIntfHelpers import *
> @@ -378,16 +379,7 @@ def createPreExistFSOptionSection(origrequest, maintable, row, mountCombo,
>          else:
>              value = origrequest.size
>  
> -        reqlower = 1
> -        requpper = origrequest.maxSize
> -
> -        if origfs.exists:
> -            reqlower = origrequest.minSize
> -
> -            if origrequest.type == "partition":
> -                geomsize = origrequest.partedPartition.geometry.getSize(unit="MB")
> -                if (geomsize != 0) and (requpper > geomsize):
> -                    requpper = geomsize
> +        (reqlower, requpper) = getResizeMinMax( origrequest )
>  
>          adj = gtk.Adjustment(value = value, lower = reqlower,
>                               upper = requpper, step_incr = 1)
> @@ -435,3 +427,18 @@ def doUIRAIDLVMChecks(format, req_disks, storage):
>  		      "drive in the 'Allowable Drives' checklist.")
>                      % format.name)
>  
> +def getResizeMinMax( part ):
> +    """ Return the minimum/maximum size for a selected partition
> +
> +        Assumes that it is resizable and that it exists.
> +    """
> +    reqlower = long(math.ceil(part.minSize))
> +    requpper = long(math.floor(part.maxSize))
> +
> +    if part.type == "partition":
> +        geomsize = part.partedPartition.geometry.getSize(unit="MB")
> +        if (geomsize != 0) and (requpper > geomsize):
> +            requpper =long(math.floor(geomsize))
> +
> +    return(reqlower, requpper)
> +


_______________________________________________
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