[gparted] Make resize_move_partition() skip whole disk device partitions (#775932)



commit 7caebd2515509022ea8ec4fe505948ab1b758015
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Nov 14 20:26:29 2016 +0000

    Make resize_move_partition() skip whole disk device partitions (#775932)
    
    Make the logic at the resize_move_partition() call sites a little
    simpler by not having to avoid calling it for whole disk device
    partitions.  Make it a successful non-operation in that case.
    
    Bug 775932 - Refactor mostly applying of operations

 src/GParted_Core.cc |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index db4545b..f1f1da8 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2508,8 +2508,7 @@ bool GParted_Core::resize( const Partition & partition_old,
        if ( partition_new.filesystem == FS_LINUX_SWAP )
        {
                // linux-swap is recreated, not resize
-               success =    ( partition_new.whole_device ||
-                              resize_move_partition( partition_old, partition_new, operationdetail ) )
+               success =    resize_move_partition( partition_old, partition_new, operationdetail )
                          && resize_filesystem( partition_old, partition_new, operationdetail );
 
                return success;
@@ -2520,14 +2519,12 @@ bool GParted_Core::resize( const Partition & partition_old,
        {
                success =    check_repair_filesystem( partition_new, operationdetail )
                          && resize_filesystem( partition_old, partition_new, operationdetail )
-                         && ( partition_new.whole_device ||
-                              resize_move_partition( partition_old, partition_new, operationdetail ) );
+                         && resize_move_partition( partition_old, partition_new, operationdetail );
        }
        else if ( delta > 0LL )  // grow
        {
                success =    check_repair_filesystem( partition_new, operationdetail )
-                         && ( partition_new.whole_device ||
-                              resize_move_partition( partition_old, partition_new, operationdetail ) )
+                         && resize_move_partition( partition_old, partition_new, operationdetail )
                          && maximize_filesystem( partition_new, operationdetail );
        }
 
@@ -2538,6 +2535,11 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
                                          const Partition & partition_new,
                                          OperationDetail & operationdetail )
 {
+       if ( partition_new.whole_device )
+               // Trying to resize/move a non-partitioned whole disk device is a
+               // successful non-operation.
+               return true;
+
        //i'm not too happy with this, but i think it is the correct way from a i18n POV
        enum Action
        {


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