From f9659989b18efb0e4e8eed268f5d6b85ac2ebb08 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 11:06:02 +0200 Subject: [PATCH] [partition] rename findFS Rename findFS -> canonicalFilesystemName because that's what it actually does. While here, apply coding style to the files that are affected. --- src/modules/partition/core/PartUtils.cpp | 2 +- src/modules/partition/core/PartUtils.h | 6 ++++-- src/modules/partition/core/PartitionActions.cpp | 6 ++++-- src/modules/partition/core/PartitionLayout.cpp | 2 +- src/modules/partition/gui/CreatePartitionDialog.cpp | 2 +- .../partition/gui/EditExistingPartitionDialog.cpp | 2 +- src/modules/partition/gui/PartitionViewStep.cpp | 9 ++++----- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 368d04af2..8d048b297 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -472,7 +472,7 @@ isEfiBootable( const Partition* candidate ) } QString -findFS( QString fsName, FileSystem::Type* fsType ) +canonicalFilesystemName( const QString& fsName, FileSystem::Type* fsType ) { QStringList fsLanguage { QLatin1String( "C" ) }; // Required language list to turn off localization if ( fsName.isEmpty() ) diff --git a/src/modules/partition/core/PartUtils.h b/src/modules/partition/core/PartUtils.h index aec345882..89d2c5e1a 100644 --- a/src/modules/partition/core/PartUtils.h +++ b/src/modules/partition/core/PartUtils.h @@ -91,11 +91,13 @@ bool isEfiBootable( const Partition* candidate ); /** @brief translate @p fsName into a recognized name and type * * Makes several attempts to translate the string into a - * name that KPMCore will recognize. + * name that KPMCore will recognize. Returns the canonical + * filesystem name (e.g. asking for "EXT4" will return "ext4"). + * * The corresponding filesystem type is stored in @p fsType, and * its value is FileSystem::Unknown if @p fsName is not recognized. */ -QString findFS( QString fsName, FileSystem::Type* fsType ); +QString canonicalFilesystemName( const QString& fsName, FileSystem::Type* fsType ); } // namespace PartUtils diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 728eda767..422c1d38f 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -108,8 +108,10 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO partType = isEfi ? PartitionTable::gpt : PartitionTable::msdos; } - FileSystem::Type type; - PartUtils::findFS( o.defaultFsType, &type ); + // Looking up the defaultFsType (which should name a filesystem type) + // will log an error and set the type to Unknown if there's something wrong. + FileSystem::Type type = FileSystem::Unknown; + PartUtils::canonicalFilesystemName( o.defaultFsType, &type ); core->initLayout( type == FileSystem::Unknown ? FileSystem::Ext4 : type ); core->createPartitionTable( dev, partType ); diff --git a/src/modules/partition/core/PartitionLayout.cpp b/src/modules/partition/core/PartitionLayout.cpp index 23eaeda62..c828fce69 100644 --- a/src/modules/partition/core/PartitionLayout.cpp +++ b/src/modules/partition/core/PartitionLayout.cpp @@ -75,7 +75,7 @@ PartitionLayout::PartitionEntry::PartitionEntry( const QString& label, , partMinSize( minSize ) , partMaxSize( maxSize ) { - PartUtils::findFS( fs, &partFileSystem ); + PartUtils::canonicalFilesystemName( fs, &partFileSystem ); } diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index c765bf1f7..4236022be 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -96,7 +96,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, // File system; the config value is translated (best-effort) to a type FileSystem::Type defaultFSType; - QString untranslatedFSName = PartUtils::findFS( + QString untranslatedFSName = PartUtils::canonicalFilesystemName( Calamares::JobQueue::instance()->globalStorage()->value( "defaultFileSystemType" ).toString(), &defaultFSType ); if ( defaultFSType == FileSystem::Type::Unknown ) { diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index e2d7ac5ba..411d6d0dc 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -97,7 +97,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, m_ui->fileSystemComboBox->addItems( fsNames ); FileSystem::Type defaultFSType; - QString untranslatedFSName = PartUtils::findFS( + QString untranslatedFSName = PartUtils::canonicalFilesystemName( Calamares::JobQueue::instance()->globalStorage()->value( "defaultFileSystemType" ).toString(), &defaultFSType ); if ( defaultFSType == FileSystem::Type::Unknown ) { diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index b4eefb3b0..52bf1fc3b 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -388,7 +388,7 @@ shouldWarnForGPTOnBIOS( const PartitionCoreModule* core ) } auto [ r, device ] = core->bootLoaderModel()->findBootLoader( core->bootLoaderInstallPath() ); - Q_UNUSED(r); + Q_UNUSED( r ); if ( device ) { auto* table = device->partitionTable(); @@ -403,8 +403,7 @@ shouldWarnForGPTOnBIOS( const PartitionCoreModule* core ) && ( partition->fileSystem().type() == FileSystem::Unformatted ) && ( partition->capacity() >= 8_MiB ) ) { - cDebug() << Logger::SubEntry << "Partition" << partition->devicePath() - << partition->partitionPath() + cDebug() << Logger::SubEntry << "Partition" << partition->devicePath() << partition->partitionPath() << "is a suitable bios_grub partition"; return false; } @@ -591,7 +590,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { cWarning() << "Partition-module setting *defaultFileSystemType* is missing, will use ext4"; } - QString fsRealName = PartUtils::findFS( fsName, &fsType ); + QString fsRealName = PartUtils::canonicalFilesystemName( fsName, &fsType ); if ( fsRealName == fsName ) { cDebug() << o << "Partition-module setting *defaultFileSystemType*" << fsRealName; @@ -619,7 +618,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) // because it could take a while. Then when it's done, we can set up the widgets // and remove the spinner. m_future = new QFutureWatcher< void >(); - connect( m_future, &QFutureWatcher< void >::finished, this, [ this ] { + connect( m_future, &QFutureWatcher< void >::finished, this, [this] { continueLoading(); this->m_future->deleteLater(); this->m_future = nullptr;