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