Don't fail when trying to replace unallocated space.

main
Teo Mrnjavac 9 years ago
parent 3ff23e8bc4
commit 24c1bf429e

@ -201,10 +201,23 @@ void
doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition ) doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition )
{ {
cDebug() << "doReplacePartition for device" << partition->partitionPath(); cDebug() << "doReplacePartition for device" << partition->partitionPath();
PartitionRole newRoles( partition->roles() ); PartitionRole newRoles( partition->roles() );
if ( partition->roles().has( PartitionRole::Extended ) ) if ( partition->roles().has( PartitionRole::Extended ) )
newRoles = PartitionRole( PartitionRole::Primary ); newRoles = PartitionRole( PartitionRole::Primary );
if ( partition->roles().has( PartitionRole::Unallocated ) )
{
newRoles = PartitionRole( PartitionRole::Primary );
cDebug() << "WARNING: selected partition is free space";
if ( partition->parent() )
{
Partition* parent = dynamic_cast< Partition* >( partition->parent() );
if ( parent && parent->roles().has( PartitionRole::Extended ) )
newRoles = PartitionRole( PartitionRole::Logical );
}
}
Partition* newPartition = KPMHelpers::createNewPartition( Partition* newPartition = KPMHelpers::createNewPartition(
partition->parent(), partition->parent(),
*dev, *dev,
@ -215,7 +228,8 @@ doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition
PartitionInfo::setMountPoint( newPartition, "/" ); PartitionInfo::setMountPoint( newPartition, "/" );
PartitionInfo::setFormat( newPartition, true ); PartitionInfo::setFormat( newPartition, true );
core->deletePartition( dev, partition ); if ( !partition->roles().has( PartitionRole::Unallocated ) )
core->deletePartition( dev, partition );
core->createPartition( dev, newPartition ); core->createPartition( dev, newPartition );
core->dumpQueue(); core->dumpQueue();

Loading…
Cancel
Save