[partition] Improve check canBeResized

- Report the globalSettings name properly (with "GiB")
 - Bail out on bad conversion early.
This commit is contained in:
Adriaan de Groot 2019-06-07 22:51:33 +02:00
parent 830e67fae2
commit 3548792d1b

View File

@ -148,20 +148,23 @@ canBeResized( Partition* candidate )
->globalStorage() ->globalStorage()
->value( "requiredStorageGiB" ) ->value( "requiredStorageGiB" )
.toDouble( &ok ); .toDouble( &ok );
if ( !ok )
{
cDebug() << Logger::SubEntry << "NO, requiredStorageGiB is not set correctly.";
return false;
}
// We require a little more for partitioning overhead and swap file // We require a little more for partitioning overhead and swap file
double advisedStorageGB = requiredStorageGB + 0.5 + 2.0; double advisedStorageGB = requiredStorageGB + 0.5 + 2.0;
qint64 availableStorageB = candidate->available(); qint64 availableStorageB = candidate->available();
qint64 advisedStorageB = CalamaresUtils::GiBtoBytes( advisedStorageGB ); qint64 advisedStorageB = CalamaresUtils::GiBtoBytes( advisedStorageGB );
if ( ok && if ( availableStorageB > advisedStorageB )
availableStorageB > advisedStorageB )
{ {
cDebug() << "Partition" << convenienceName( candidate ) << "authorized for resize + autopartition install."; cDebug() << "Partition" << convenienceName( candidate ) << "authorized for resize + autopartition install.";
return true; return true;
} }
else if ( ok ) else
{ {
Logger::CDebug deb; Logger::CDebug deb;
deb << Logger::SubEntry << "NO, insufficient storage"; deb << Logger::SubEntry << "NO, insufficient storage";
@ -173,11 +176,6 @@ canBeResized( Partition* candidate )
<< "sectorsUsed:" << candidate->sectorsUsed() << "fsType:" << candidate->fileSystem().name(); << "sectorsUsed:" << candidate->sectorsUsed() << "fsType:" << candidate->fileSystem().name();
return false; return false;
} }
else
{
cDebug() << Logger::SubEntry << "NO, requiredStorageGB is not set correctly.";
return false;
}
} }