diff --git a/src/libcalamares/partition/Tests.cpp b/src/libcalamares/partition/Tests.cpp index a456d7e36..16f7d78c2 100644 --- a/src/libcalamares/partition/Tests.cpp +++ b/src/libcalamares/partition/Tests.cpp @@ -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" ) ); } diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index 1660dbb54..f79918e64 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -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