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



commit 829bf0ccc1ac8dd60227d88b2535fab5bf61d68b
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Nov 7 22:10:35 2016 +0000

    Make set_partition_type() skip whole disk device partitions (#775932)
    
    Make the logic at the set_partition_type() call sites a little simpler
    by not having to avoid calling it for whole disk device Partition
    objects.  Make set_partition_type() handle those itself as a silent
    non-operation.
    
    This is similar to how calibrate_partition() could be called on an
    UNALLOCATED Partition object, and update_bootsector() is called on
    non-NTFS file system Partition objects.  Both are successful and silent
    non-operations.
    
    Bug 775932 - Refactor mostly applying of operations

 src/GParted_Core.cc |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index dadc18a..40f0dcc 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2046,9 +2046,6 @@ bool GParted_Core::format( const Partition & partition, OperationDetail & operat
 {
        if ( partition .filesystem == FS_CLEARED )
                return erase_filesystem_signatures( partition, operationdetail ) ;
-       else if ( partition.whole_device )
-               return    erase_filesystem_signatures( partition, operationdetail )
-                      && create_filesystem( partition, operationdetail );
        else
                return    erase_filesystem_signatures( partition, operationdetail )
                       && set_partition_type( partition, operationdetail )
@@ -2856,14 +2853,8 @@ bool GParted_Core::copy( const Partition & partition_src,
                        return false;
        }
 
-       if ( ! partition_dst.whole_device )
-       {
-               // Only set type of partition on a partitioned device.
-               if ( ! set_partition_type( partition_dst, operationdetail ) )
-                       return false;
-       }
-
-       bool success =    copy_filesystem( partition_src, partition_dst, operationdetail )
+       bool success =    set_partition_type( partition_dst, operationdetail )
+                      && copy_filesystem( partition_src, partition_dst, operationdetail )
                       && update_bootsector( partition_dst, operationdetail );
        if ( ! success )
                return false;
@@ -3150,6 +3141,11 @@ bool GParted_Core::check_repair_filesystem( const Partition & partition, Operati
 
 bool GParted_Core::set_partition_type( const Partition & partition, OperationDetail & operationdetail )
 {
+       if ( partition.whole_device )
+               // Trying to set the type of a partition on a non-partitioned whole disk
+               // device is a successful non-operation.
+               return true;
+
        operationdetail .add_child( OperationDetail(
                                String::ucompose( _("set partition type on %1"), partition .get_path() ) ) ) ;
        //Set partition type appropriately for the type of file system stored in the partition.


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