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
This commit is contained in:
Mike Fleetwood 2016-11-07 22:10:35 +00:00 committed by Curtis Gedak
parent 9f08875997
commit 829bf0ccc1
1 changed files with 7 additions and 11 deletions

View File

@ -2046,9 +2046,6 @@ bool GParted_Core::format( const Partition & partition, OperationDetail & operat
{ {
if ( partition .filesystem == FS_CLEARED ) if ( partition .filesystem == FS_CLEARED )
return erase_filesystem_signatures( partition, operationdetail ) ; return erase_filesystem_signatures( partition, operationdetail ) ;
else if ( partition.whole_device )
return erase_filesystem_signatures( partition, operationdetail )
&& create_filesystem( partition, operationdetail );
else else
return erase_filesystem_signatures( partition, operationdetail ) return erase_filesystem_signatures( partition, operationdetail )
&& set_partition_type( partition, operationdetail ) && set_partition_type( partition, operationdetail )
@ -2856,14 +2853,8 @@ bool GParted_Core::copy( const Partition & partition_src,
return false; return false;
} }
if ( ! partition_dst.whole_device ) bool success = set_partition_type( partition_dst, operationdetail )
{ && copy_filesystem( partition_src, partition_dst, operationdetail )
// 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 )
&& update_bootsector( partition_dst, operationdetail ); && update_bootsector( partition_dst, operationdetail );
if ( ! success ) if ( ! success )
return false; 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 ) 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( operationdetail .add_child( OperationDetail(
String::ucompose( _("set partition type on %1"), partition .get_path() ) ) ) ; String::ucompose( _("set partition type on %1"), partition .get_path() ) ) ) ;
//Set partition type appropriately for the type of file system stored in the partition. //Set partition type appropriately for the type of file system stored in the partition.