diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 8c736042f..440d437bc 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -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 diff --git a/src/modules/partition/core/PartUtils.h b/src/modules/partition/core/PartUtils.h index de3008a01..84b492f4a 100644 --- a/src/modules/partition/core/PartUtils.h +++ b/src/modules/partition/core/PartUtils.h @@ -29,6 +29,8 @@ class Partition; namespace PartUtils { +bool canBeReplaced( Partition* candidate ); + bool canBeResized( Partition* candidate ); bool canBeResized( PartitionCoreModule* core, const QString& partitionPath );