[partition] Use structured logging
- Structured logging - Reduce chattiness - Use helper functions - Some TODO were done a while ago
This commit is contained in:
parent
04146df36b
commit
4caa401a07
@ -109,20 +109,20 @@ canBeResized( Partition* candidate )
|
|||||||
if ( !candidate->fileSystem().supportGrow() ||
|
if ( !candidate->fileSystem().supportGrow() ||
|
||||||
!candidate->fileSystem().supportShrink() )
|
!candidate->fileSystem().supportShrink() )
|
||||||
{
|
{
|
||||||
cDebug() << " .. filesystem" << candidate->fileSystem().name()
|
cDebug() << Logger::SubEntry() << "NO, filesystem" << candidate->fileSystem().name()
|
||||||
<< "does not support resize.";
|
<< "does not support resize.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( KPMHelpers::isPartitionFreeSpace( candidate ) )
|
if ( KPMHelpers::isPartitionFreeSpace( candidate ) )
|
||||||
{
|
{
|
||||||
cDebug() << " .. partition is free space";
|
cDebug() << Logger::SubEntry() << "NO, partition is free space";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( candidate->isMounted() )
|
if ( candidate->isMounted() )
|
||||||
{
|
{
|
||||||
cDebug() << " .. partition is mounted";
|
cDebug() << Logger::SubEntry() << "NO, partition is mounted";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,13 +131,13 @@ canBeResized( Partition* candidate )
|
|||||||
PartitionTable* table = dynamic_cast< PartitionTable* >( candidate->parent() );
|
PartitionTable* table = dynamic_cast< PartitionTable* >( candidate->parent() );
|
||||||
if ( !table )
|
if ( !table )
|
||||||
{
|
{
|
||||||
cDebug() << " .. no partition table found";
|
cDebug() << Logger::SubEntry() << "NO, no partition table found";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( table->numPrimaries() >= table->maxPrimaries() )
|
if ( table->numPrimaries() >= table->maxPrimaries() )
|
||||||
{
|
{
|
||||||
cDebug() << " .. partition table already has"
|
cDebug() << Logger::SubEntry() << "NO, partition table already has"
|
||||||
<< table->maxPrimaries() << "primary partitions.";
|
<< table->maxPrimaries() << "primary partitions.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -148,19 +148,11 @@ canBeResized( Partition* candidate )
|
|||||||
->globalStorage()
|
->globalStorage()
|
||||||
->value( "requiredStorageGB" )
|
->value( "requiredStorageGB" )
|
||||||
.toDouble( &ok );
|
.toDouble( &ok );
|
||||||
|
// 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();
|
||||||
|
|
||||||
// We require a little more for partitioning overhead and swap file
|
qint64 advisedStorageB = CalamaresUtils::GiBtoBytes( advisedStorageGB );
|
||||||
// TODO: maybe make this configurable?
|
|
||||||
qint64 advisedStorageB = advisedStorageGB * 1024 * 1024 * 1024;
|
|
||||||
cDebug() << "Required storage B:" << advisedStorageB
|
|
||||||
<< QString( "(%1GB)" ).arg( advisedStorageGB );
|
|
||||||
cDebug() << "Available storage B:" << availableStorageB
|
|
||||||
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
|
||||||
<< "for" << convenienceName( candidate ) << " length:" << candidate->length()
|
|
||||||
<< " sectorsUsed:" << candidate->sectorsUsed() << " fsType:" << candidate->fileSystem().name();
|
|
||||||
|
|
||||||
if ( ok &&
|
if ( ok &&
|
||||||
availableStorageB > advisedStorageB )
|
availableStorageB > advisedStorageB )
|
||||||
@ -169,14 +161,29 @@ canBeResized( Partition* candidate )
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if ( ok )
|
||||||
|
{
|
||||||
|
auto deb = cDebug();
|
||||||
|
deb << Logger::SubEntry() << "NO, insufficient storage";
|
||||||
|
deb << Logger::Continuation() << "Required storage B:" << advisedStorageB
|
||||||
|
<< QString( "(%1GB)" ).arg( advisedStorageGB );
|
||||||
|
deb << Logger::Continuation() << "Available storage B:" << availableStorageB
|
||||||
|
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
||||||
|
<< "for" << convenienceName( candidate ) << " length:" << candidate->length()
|
||||||
|
<< " sectorsUsed:" << candidate->sectorsUsed() << " fsType:" << candidate->fileSystem().name();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry() << "NO, requiredStorageGB is not set correctly.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
canBeResized( PartitionCoreModule* core, const QString& partitionPath )
|
canBeResized( PartitionCoreModule* core, const QString& partitionPath )
|
||||||
{
|
{
|
||||||
//FIXME: check for max partitions count on DOS MBR
|
|
||||||
cDebug() << "Checking if" << partitionPath << "can be resized.";
|
cDebug() << "Checking if" << partitionPath << "can be resized.";
|
||||||
QString partitionWithOs = partitionPath;
|
QString partitionWithOs = partitionPath;
|
||||||
if ( partitionWithOs.startsWith( "/dev/" ) )
|
if ( partitionWithOs.startsWith( "/dev/" ) )
|
||||||
@ -188,14 +195,13 @@ canBeResized( PartitionCoreModule* core, const QString& partitionPath )
|
|||||||
Partition* candidate = KPMHelpers::findPartitionByPath( { dev }, partitionWithOs );
|
Partition* candidate = KPMHelpers::findPartitionByPath( { dev }, partitionWithOs );
|
||||||
if ( candidate )
|
if ( candidate )
|
||||||
{
|
{
|
||||||
cDebug() << " .. found Partition* for" << partitionWithOs;
|
|
||||||
return canBeResized( candidate );
|
return canBeResized( candidate );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cDebug() << " .. no Partition* found for" << partitionWithOs;
|
cDebug() << Logger::SubEntry() << "no Partition* found for" << partitionWithOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
cDebug() << "Partition" << partitionWithOs << "CANNOT BE RESIZED FOR AUTOINSTALL.";
|
cDebug() << Logger::SubEntry() << "Partition" << partitionWithOs << "CANNOT BE RESIZED FOR AUTOINSTALL.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user