[partition] Fix parsing of partition size in partition layout

When setting the size of a partition without indicating the unit, two
problems occur:

- the size is parsed as an integer, not as a string, hence the
configuration parsing fails
- the size parser doesn't recognize the fact that the size has no units
and defaults to 100%

This patch fixes the configuration parsing as well as the size string
parsing.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
This commit is contained in:
Arnaud Ferraris 2019-02-01 14:02:40 +01:00
parent 18bb71aceb
commit cf45d55b32
2 changed files with 24 additions and 4 deletions

View file

@ -772,17 +772,30 @@ PartitionCoreModule::initLayout()
void
PartitionCoreModule::initLayout( const QVariantList& config )
{
QString sizeString;
QString minSizeString;
m_partLayout = new PartitionLayout();
for ( const auto& r : config )
{
QVariantMap pentry = r.toMap();
if ( pentry.contains("size") && CalamaresUtils::getString( pentry, "size" ).isEmpty() )
sizeString.setNum( CalamaresUtils::getInteger( pentry, "size", 0 ) );
else
sizeString = CalamaresUtils::getString( pentry, "size" );
if ( pentry.contains("minSize") && CalamaresUtils::getString( pentry, "minSize" ).isEmpty() )
minSizeString.setNum( CalamaresUtils::getInteger( pentry, "minSize", 0 ) );
else
minSizeString = CalamaresUtils::getString( pentry, "minSize" );
m_partLayout->addEntry( CalamaresUtils::getString( pentry, "name" ),
CalamaresUtils::getString( pentry, "mountPoint" ),
CalamaresUtils::getString( pentry, "filesystem" ),
CalamaresUtils::getString( pentry, "size" ),
CalamaresUtils::getString( pentry, "minSize" )
sizeString,
minSizeString
);
}
}