From 22dbe60bb9dcb92619a7e83729711f4e96a2fb2c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 28 Mar 2021 18:07:32 +0200 Subject: [PATCH] [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() ); }