[partition] Use convenience function for running operations
This commit is contained in:
parent
1356012fb4
commit
b8ce21d572
@ -14,7 +14,8 @@
|
||||
#include "partition/PartitionIterator.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
// KPMcore
|
||||
#include "core/KPMHelpers.h"
|
||||
|
||||
#include <kpmcore/core/device.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include <kpmcore/core/partitiontable.h>
|
||||
@ -63,8 +64,6 @@ CreatePartitionTableJob::prettyStatusMessage() const
|
||||
Calamares::JobResult
|
||||
CreatePartitionTableJob::exec()
|
||||
{
|
||||
Report report( nullptr );
|
||||
QString message = tr( "The installer failed to create a partition table on %1." ).arg( m_device->name() );
|
||||
|
||||
PartitionTable* table = m_device->partitionTable();
|
||||
|
||||
@ -91,15 +90,9 @@ CreatePartitionTableJob::exec()
|
||||
cDebug() << Logger::SubEntry << "mount output:\n" << Logger::NoQuote << mount.readAllStandardOutput();
|
||||
}
|
||||
|
||||
CreatePartitionTableOperation op( *m_device, table );
|
||||
op.setStatus( Operation::StatusRunning );
|
||||
|
||||
if ( op.execute( report ) )
|
||||
{
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
||||
return Calamares::JobResult::error( message, report.toText() );
|
||||
return KPMHelpers::execute(
|
||||
CreatePartitionTableOperation( *m_device, table ),
|
||||
tr( "The installer failed to create a partition table on %1." ).arg( m_device->name() ) );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -9,7 +9,8 @@
|
||||
|
||||
#include "CreateVolumeGroupJob.h"
|
||||
|
||||
// KPMcore
|
||||
#include "core/KPMHelpers.h"
|
||||
|
||||
#include <kpmcore/core/lvmdevice.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include <kpmcore/ops/createvolumegroupoperation.h>
|
||||
@ -46,19 +47,8 @@ CreateVolumeGroupJob::prettyStatusMessage() const
|
||||
Calamares::JobResult
|
||||
CreateVolumeGroupJob::exec()
|
||||
{
|
||||
Report report( nullptr );
|
||||
|
||||
CreateVolumeGroupOperation op( m_vgName, m_pvList, m_peSize );
|
||||
|
||||
op.setStatus( Operation::StatusRunning );
|
||||
|
||||
QString message = tr( "The installer failed to create a volume group named '%1'." ).arg( m_vgName );
|
||||
if ( op.execute( report ) )
|
||||
{
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
||||
return Calamares::JobResult::error( message, report.toText() );
|
||||
return KPMHelpers::execute( CreateVolumeGroupOperation( m_vgName, m_pvList, m_peSize ),
|
||||
tr( "The installer failed to create a volume group named '%1'." ).arg( m_vgName ) );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "FormatPartitionJob.h"
|
||||
|
||||
#include "core/KPMHelpers.h"
|
||||
|
||||
#include "partition/FileSystem.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
@ -65,17 +67,7 @@ FormatPartitionJob::prettyStatusMessage() const
|
||||
Calamares::JobResult
|
||||
FormatPartitionJob::exec()
|
||||
{
|
||||
Report report( nullptr ); // Root of the report tree, no parent
|
||||
CreateFileSystemOperation op( *m_device, *m_partition, m_partition->fileSystem().type() );
|
||||
op.setStatus( Operation::StatusRunning );
|
||||
|
||||
QString message = tr( "The installer failed to format partition %1 on disk '%2'." )
|
||||
.arg( m_partition->partitionPath(), m_device->name() );
|
||||
|
||||
if ( op.execute( report ) )
|
||||
{
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
||||
return Calamares::JobResult::error( message, report.toText() );
|
||||
return KPMHelpers::execute( CreateFileSystemOperation( *m_device, *m_partition, m_partition->fileSystem().type() ),
|
||||
tr( "The installer failed to format partition %1 on disk '%2'." )
|
||||
.arg( m_partition->partitionPath(), m_device->name() ) );
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#include "RemoveVolumeGroupJob.h"
|
||||
|
||||
#include "core/KPMHelpers.h"
|
||||
|
||||
#include <kpmcore/core/lvmdevice.h>
|
||||
#include <kpmcore/ops/removevolumegroupoperation.h>
|
||||
#include <kpmcore/util/report.h>
|
||||
@ -39,17 +41,7 @@ RemoveVolumeGroupJob::prettyStatusMessage() const
|
||||
Calamares::JobResult
|
||||
RemoveVolumeGroupJob::exec()
|
||||
{
|
||||
Report report( nullptr );
|
||||
|
||||
RemoveVolumeGroupOperation op( *m_device );
|
||||
|
||||
op.setStatus( Operation::OperationStatus::StatusRunning );
|
||||
|
||||
QString message = tr( "The installer failed to remove a volume group named '%1'." ).arg( m_device->name() );
|
||||
if ( op.execute( report ) )
|
||||
{
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
||||
return Calamares::JobResult::error( message, report.toText() );
|
||||
return KPMHelpers::execute(
|
||||
RemoveVolumeGroupOperation( *m_device ),
|
||||
tr( "The installer failed to remove a volume group named '%1'." ).arg( m_device->name() ) );
|
||||
}
|
||||
|
@ -9,7 +9,8 @@
|
||||
|
||||
#include "ResizeVolumeGroupJob.h"
|
||||
|
||||
// KPMcore
|
||||
#include "core/KPMHelpers.h"
|
||||
|
||||
#include <kpmcore/core/lvmdevice.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include <kpmcore/ops/resizevolumegroupoperation.h>
|
||||
@ -51,19 +52,9 @@ ResizeVolumeGroupJob::prettyStatusMessage() const
|
||||
Calamares::JobResult
|
||||
ResizeVolumeGroupJob::exec()
|
||||
{
|
||||
Report report( nullptr );
|
||||
|
||||
ResizeVolumeGroupOperation op( *m_device, m_partitionList );
|
||||
|
||||
op.setStatus( Operation::OperationStatus::StatusRunning );
|
||||
|
||||
QString message = tr( "The installer failed to resize a volume group named '%1'." ).arg( m_device->name() );
|
||||
if ( op.execute( report ) )
|
||||
{
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
||||
return Calamares::JobResult::error( message, report.toText() );
|
||||
return KPMHelpers::execute(
|
||||
ResizeVolumeGroupOperation( *m_device, m_partitionList ),
|
||||
tr( "The installer failed to resize a volume group named '%1'." ).arg( m_device->name() ) );
|
||||
}
|
||||
|
||||
QString
|
||||
|
Loading…
Reference in New Issue
Block a user