[partition] Use (better documented) filesystem-use API
This commit is contained in:
parent
10bec1d970
commit
559b79f920
@ -209,6 +209,13 @@ PartitionServiceTests::testFilesystemGS()
|
||||
useFilesystemGS( &gs, "EXT4", false );
|
||||
QVERIFY( !isFilesystemUsedGS( &gs, "EXT4" ) );
|
||||
QCOMPARE( isFilesystemUsedGS( &gs, "EXT4" ), isFilesystemUsedGS( &gs, "ext4" ) );
|
||||
useFilesystemGS( &gs, "ext4", true );
|
||||
QVERIFY( isFilesystemUsedGS( &gs, "EXT4" ) );
|
||||
|
||||
CalamaresUtils::Partition::clearFilesystemGS( &gs );
|
||||
QVERIFY( !isFilesystemUsedGS( &gs, "ZFS" ) );
|
||||
QVERIFY( !isFilesystemUsedGS( &gs, "EXT4" ) );
|
||||
QVERIFY( !isFilesystemUsedGS( &gs, "ext4" ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "partition/FileSystem.h"
|
||||
#include "partition/Global.h"
|
||||
#include "partition/PartitionIterator.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
@ -291,35 +292,29 @@ FillGlobalStorageJob::prettyStatusMessage() const
|
||||
* .. mark as "1" if it's on the system, somewhere
|
||||
* .. mark as "2" if it's one of the claimed / in-use FSses
|
||||
*
|
||||
* Stores a GS key called "filesystems_use" with this mapping.
|
||||
* Stores a GS key called "filesystem_use" with this mapping.
|
||||
* @see CalamaresUtils::Partition::useFilesystemGS()
|
||||
*/
|
||||
static void
|
||||
storeFSUse( Calamares::GlobalStorage* storage, const QVariantList& partitions )
|
||||
{
|
||||
QMap< QString, int > fsUses;
|
||||
for ( const auto& p : partitions )
|
||||
if ( storage )
|
||||
{
|
||||
const auto pmap = p.toMap();
|
||||
|
||||
QString fs = pmap.value( "fs" ).toString();
|
||||
int thisUse = pmap.value( "claimed" ).toBool() ? 2 : 1;
|
||||
|
||||
if ( fs.isEmpty() )
|
||||
CalamaresUtils::Partition::clearFilesystemGS( storage );
|
||||
for ( const auto& p : partitions )
|
||||
{
|
||||
continue;
|
||||
const auto pmap = p.toMap();
|
||||
|
||||
QString fs = pmap.value( "fs" ).toString();
|
||||
|
||||
if ( fs.isEmpty() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CalamaresUtils::Partition::useFilesystemGS( storage, fs, true );
|
||||
}
|
||||
|
||||
int newUse = qMax( fsUses.value( fs ), thisUse ); // value() is 0 if not present
|
||||
fsUses.insert( fs, newUse );
|
||||
}
|
||||
|
||||
QVariantMap fsUsesVariant;
|
||||
for ( auto it = fsUses.cbegin(); it != fsUses.cend(); ++it )
|
||||
{
|
||||
fsUsesVariant.insert( it.key(), it.value() );
|
||||
}
|
||||
|
||||
storage->insert( "filesystems_use", fsUsesVariant );
|
||||
}
|
||||
|
||||
Calamares::JobResult
|
||||
|
Loading…
Reference in New Issue
Block a user