From ceba157459f6515dac47f6fb27a2687624e1e735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Thu, 12 Oct 2017 18:59:11 +0100 Subject: [PATCH] Use KPMcore DeleteOperation to delete partitions. --- .../partition/jobs/DeletePartitionJob.cpp | 47 +++---------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/src/modules/partition/jobs/DeletePartitionJob.cpp b/src/modules/partition/jobs/DeletePartitionJob.cpp index bceffd133..1bed8739f 100644 --- a/src/modules/partition/jobs/DeletePartitionJob.cpp +++ b/src/modules/partition/jobs/DeletePartitionJob.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include DeletePartitionJob::DeletePartitionJob( Device* device, Partition* partition ) @@ -65,48 +66,14 @@ Calamares::JobResult DeletePartitionJob::exec() { Report report( nullptr ); + DeleteOperation op(*m_device, m_partition); + op.setStatus(Operation::StatusRunning); + QString message = tr( "The installer failed to delete partition %1." ).arg( m_partition->devicePath() ); + if (op.execute(report)) + return Calamares::JobResult::ok(); - if ( m_device->deviceNode() != m_partition->devicePath() ) - { - return Calamares::JobResult::error( - message, - tr( "Partition (%1) and device (%2) do not match." ) - .arg( m_partition->devicePath() ) - .arg( m_device->deviceNode() ) - ); - } - - CoreBackend* backend = CoreBackendManager::self()->backend(); - QScopedPointer backendDevice( backend->openDevice( m_device->deviceNode() ) ); - if ( !backendDevice.data() ) - { - return Calamares::JobResult::error( - message, - tr( "Could not open device %1." ).arg( m_device->deviceNode() ) - ); - } - - QScopedPointer backendPartitionTable( backendDevice->openPartitionTable() ); - if ( !backendPartitionTable.data() ) - { - return Calamares::JobResult::error( - message, - tr( "Could not open partition table." ) - ); - } - - bool ok = backendPartitionTable->deletePartition( report, *m_partition ); - if ( !ok ) - { - return Calamares::JobResult::error( - message, - report.toText() - ); - } - - backendPartitionTable->commit(); - return Calamares::JobResult::ok(); + return Calamares::JobResult::error(message, report.toText()); } void