Use KPMcore DeleteOperation to delete partitions.
This commit is contained in:
parent
70573543f2
commit
ceba157459
@ -29,6 +29,7 @@
|
|||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/core/partitiontable.h>
|
#include <kpmcore/core/partitiontable.h>
|
||||||
#include <kpmcore/fs/filesystem.h>
|
#include <kpmcore/fs/filesystem.h>
|
||||||
|
#include <kpmcore/ops/deleteoperation.h>
|
||||||
#include <kpmcore/util/report.h>
|
#include <kpmcore/util/report.h>
|
||||||
|
|
||||||
DeletePartitionJob::DeletePartitionJob( Device* device, Partition* partition )
|
DeletePartitionJob::DeletePartitionJob( Device* device, Partition* partition )
|
||||||
@ -65,48 +66,14 @@ Calamares::JobResult
|
|||||||
DeletePartitionJob::exec()
|
DeletePartitionJob::exec()
|
||||||
{
|
{
|
||||||
Report report( nullptr );
|
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() );
|
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, report.toText());
|
||||||
{
|
|
||||||
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<CoreBackendDevice> 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<CoreBackendPartitionTable> 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user