mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-26 00:48:22 -04:00
[partition] Update canBeReplaced
- Use GiB consistently - Provide same kind of debugging information as canBeResized()
This commit is contained in:
parent
79934aa513
commit
b5c50c8d04
1 changed files with 25 additions and 11 deletions
|
@ -73,30 +73,44 @@ bool
|
||||||
canBeReplaced( Partition* candidate )
|
canBeReplaced( Partition* candidate )
|
||||||
{
|
{
|
||||||
if ( !candidate )
|
if ( !candidate )
|
||||||
|
{
|
||||||
|
cDebug() << "Partition* is NULL";
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cDebug() << "Checking if" << convenienceName( candidate ) << "can be replaced.";
|
||||||
if ( candidate->isMounted() )
|
if ( candidate->isMounted() )
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << "NO, it is mounted.";
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
double requiredStorageGB = getRequiredStorageGiB( ok );
|
double requiredStorageGiB = getRequiredStorageGiB( ok );
|
||||||
|
if ( !ok )
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << "NO, requiredStorageGiB is not set correctly.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
qint64 availableStorageB = candidate->capacity();
|
qint64 availableStorageB = candidate->capacity();
|
||||||
qint64 requiredStorageB = ( requiredStorageGB + 0.5 ) * 1024 * 1024 * 1024;
|
qint64 requiredStorageB = CalamaresUtils::GiBtoBytes( requiredStorageGiB + 0.5 );
|
||||||
cDebug() << "Required storage B:" << requiredStorageB
|
|
||||||
<< QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 );
|
|
||||||
cDebug() << "Storage capacity B:" << availableStorageB
|
|
||||||
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
|
||||||
<< "for" << convenienceName( candidate ) << " length:" << candidate->length();
|
|
||||||
|
|
||||||
if ( ok &&
|
if ( availableStorageB > requiredStorageB )
|
||||||
availableStorageB > requiredStorageB )
|
|
||||||
{
|
{
|
||||||
cDebug() << "Partition" << convenienceName( candidate ) << "authorized for replace install.";
|
cDebug() << "Partition" << convenienceName( candidate ) << "authorized for replace install.";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
else
|
||||||
|
{
|
||||||
|
Logger::CDebug deb;
|
||||||
|
deb << Logger::SubEntry << "NO, insufficient storage";
|
||||||
|
deb << Logger::Continuation << "Required storage B:" << requiredStorageB
|
||||||
|
<< QString( "(%1GiB)" ).arg( requiredStorageGiB );
|
||||||
|
deb << Logger::Continuation << "Available storage B:" << availableStorageB
|
||||||
|
<< QString( "(%1GiB)" ).arg( CalamaresUtils::BytesToGiB( availableStorageB ) );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue