From e2113eda38eaa904407b226204095ac28e22a1f5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 28 Mar 2021 17:52:44 +0200 Subject: [PATCH 1/3] [partition] trust in AutoMoc --- src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp b/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp index 2df2db5e4..855e5fa8b 100644 --- a/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp +++ b/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp @@ -100,6 +100,3 @@ ChangeFilesystemLabelJob::exec() backendPartitionTable->commit(); return Calamares::JobResult::ok(); } - - -#include "ChangeFilesystemLabelJob.moc" From 47c167c04305653be86f94dc893dd8974b2d6a99 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 28 Mar 2021 17:56:54 +0200 Subject: [PATCH 2/3] [partition] KPMCore removed some headers --- src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp b/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp index 855e5fa8b..5fdc106c2 100644 --- a/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp +++ b/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp @@ -12,14 +12,17 @@ #include "utils/Logger.h" #include -#include #include -#include -#include #include #include #include +#ifndef WITH_KPMCORE42API +#include +#include +#include +#endif + ChangeFilesystemLabelJob::ChangeFilesystemLabelJob( Device* device, Partition* partition, const QString& newLabel ) : PartitionJob( partition ) , m_device( device ) From 22dbe60bb9dcb92619a7e83729711f4e96a2fb2c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 28 Mar 2021 18:07:32 +0200 Subject: [PATCH 3/3] [partition] Use operations-API (available in all supported KPMCore versions) --- .../jobs/ChangeFilesystemLabelJob.cpp | 48 +++---------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp b/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp index 5fdc106c2..9541c000a 100644 --- a/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp +++ b/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp @@ -15,14 +15,9 @@ #include #include #include +#include #include -#ifndef WITH_KPMCORE42API -#include -#include -#include -#endif - ChangeFilesystemLabelJob::ChangeFilesystemLabelJob( Device* device, Partition* partition, const QString& newLabel ) : PartitionJob( partition ) , m_device( device ) @@ -64,42 +59,13 @@ ChangeFilesystemLabelJob::exec() } Report report( nullptr ); - CoreBackend* backend = CoreBackendManager::self()->backend(); + SetFileSystemLabelOperation op( *partition(), m_label ); + op.setStatus( Operation::StatusRunning ); - QScopedPointer< CoreBackendDevice > backendDevice( backend->openDevice( m_device->deviceNode() ) ); - if ( !backendDevice.data() ) + if ( op.execute( report ) ) { - return Calamares::JobResult::error( tr( "Could not open device '%1'." ).arg( m_device->deviceNode() ), - report.toText() ); + return Calamares::JobResult::ok(); } - - QScopedPointer< CoreBackendPartitionTable > backendPartitionTable( backendDevice->openPartitionTable() ); - if ( !backendPartitionTable.data() ) - { - return Calamares::JobResult::error( - tr( "Could not open partition table on device '%1'." ).arg( m_device->deviceNode() ), report.toText() ); - } - - QScopedPointer< CoreBackendPartition > backendPartition( - ( partition()->roles().has( PartitionRole::Extended ) ) - ? backendPartitionTable->getExtendedPartition() - : backendPartitionTable->getPartitionBySector( partition()->firstSector() ) ); - if ( !backendPartition.data() ) - { - return Calamares::JobResult::error( tr( "Could not find partition '%1'." ).arg( partition()->partitionPath() ), - report.toText() ); - } - - FileSystem& fs = m_partition->fileSystem(); - fs.setLabel( m_label ); - - if ( !backendPartitionTable->setPartitionSystemType( report, *m_partition ) ) - { - return Calamares::JobResult::error( - tr( "The installer failed to update partition table on disk '%1'." ).arg( m_device->name() ), - report.toText() ); - } - - backendPartitionTable->commit(); - return Calamares::JobResult::ok(); + return Calamares::JobResult::error( + tr( "The installer failed to update partition table on disk '%1'." ).arg( m_device->name() ), report.toText() ); }