New partition replace check.

main
Teo Mrnjavac 9 years ago
parent cef77d72e1
commit 935c4816d3

@ -34,6 +34,33 @@
namespace PartUtils
{
bool
canBeReplaced( Partition* candidate )
{
bool ok = false;
double requiredStorageGB = Calamares::JobQueue::instance()
->globalStorage()
->value( "requiredStorageGB" )
.toDouble( &ok );
qint64 availableStorageB = candidate->capacity();
qint64 requiredStorageB = ( requiredStorageGB + 0.5 ) * 1024 * 1024 * 1024;
cDebug() << "Required storage B:" << requiredStorageB
<< QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 );
cDebug() << "Available storage B:" << availableStorageB
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 );
if ( ok &&
availableStorageB > requiredStorageB )
{
cDebug() << "Partition" << candidate->partitionPath() << "authorized for replace install.";
return true;
}
return false;
}
bool
canBeResized( Partition* candidate )
{
@ -51,7 +78,7 @@ canBeResized( Partition* candidate )
// We require a little more for partitioning overhead and swap file
// TODO: maybe make this configurable?
qint64 requiredStorageB = ( requiredStorageGB + 0.1 + 2.0 ) * 1024 * 1024 * 1024;
qint64 requiredStorageB = ( requiredStorageGB + 0.5 + 2.0 ) * 1024 * 1024 * 1024;
cDebug() << "Required storage B:" << requiredStorageB
<< QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 );
cDebug() << "Available storage B:" << availableStorageB

@ -29,6 +29,8 @@ class Partition;
namespace PartUtils
{
bool canBeReplaced( Partition* candidate );
bool canBeResized( Partition* candidate );
bool canBeResized( PartitionCoreModule* core, const QString& partitionPath );

Loading…
Cancel
Save