Convert CreatePartitionTableJob to KPMcore operation.

This commit is contained in:
Andrius Štikonas 2017-12-22 12:42:28 +00:00 committed by Philip
parent e801c19280
commit f5479d44a0
2 changed files with 18 additions and 38 deletions

View File

@ -23,15 +23,12 @@
#include "utils/Logger.h"
// KPMcore
#include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackendmanager.h>
#include <kpmcore/backend/corebackenddevice.h>
#include <kpmcore/backend/corebackendpartitiontable.h>
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/core/partitiontable.h>
#include <kpmcore/fs/filesystem.h>
#include <kpmcore/util/report.h>
#include <core/device.h>
#include <core/partition.h>
#include <core/partitiontable.h>
#include <fs/filesystem.h>
#include <ops/createpartitiontableoperation.h>
#include <util/report.h>
// Qt
#include <QScopedPointer>
@ -75,17 +72,7 @@ CreatePartitionTableJob::exec()
Report report( nullptr );
QString message = tr( "The installer failed to create a partition table on %1." ).arg( m_device->name() );
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< PartitionTable > table( createTable() );
PartitionTable* table( createTable() );
cDebug() << "Creating new partition table of type" << table->typeName()
<< ", uncommitted yet:\n" << table;
@ -103,20 +90,13 @@ CreatePartitionTableJob::exec()
mount.waitForFinished();
cDebug() << "mount:\n" << mount.readAllStandardOutput();
bool ok = backendDevice->createPartitionTable( report, *table );
if ( !ok )
{
return Calamares::JobResult::error(
message,
QString( "Text: %1\nCommand: %2\nOutput: %3\nStatus: %4" )
.arg( report.toText() )
.arg( report.command() )
.arg( report.output() )
.arg( report.status() )
);
}
CreatePartitionTableOperation op(*m_device, table);
op.setStatus(Operation::StatusRunning);
return Calamares::JobResult::ok();
if (op.execute(report))
return Calamares::JobResult::ok();
return Calamares::JobResult::error(message, report.toText());
}
void

View File

@ -28,11 +28,11 @@
#include "Branding.h"
#include "utils/Logger.h"
// CalaPM
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/fs/filesystem.h>
#include <kpmcore/fs/luks.h>
// KPMcore
#include <core/device.h>
#include <core/partition.h>
#include <fs/filesystem.h>
#include <fs/luks.h>
// Qt
#include <QDebug>