[partition] Use lvalue-overload of execute() convenience

- These jobs may take a long time, and report progress; we need
  the operation around to be able to connect the signals and slots
This commit is contained in:
Adriaan de Groot 2021-12-11 23:26:12 +01:00
parent 6680584724
commit fdf0f208f0
2 changed files with 11 additions and 24 deletions

View File

@ -11,9 +11,10 @@
#include "ResizePartitionJob.h"
#include "core/KPMHelpers.h"
#include "utils/Units.h"
// KPMcore
#include <kpmcore/core/device.h>
#include <kpmcore/ops/resizeoperation.h>
#include <kpmcore/util/report.h>
@ -66,23 +67,16 @@ ResizePartitionJob::prettyStatusMessage() const
Calamares::JobResult
ResizePartitionJob::exec()
{
Report report( nullptr );
// Restore partition sectors that were modified for preview
m_partition->setFirstSector( m_oldFirstSector );
m_partition->setLastSector( m_oldLastSector );
ResizeOperation op( *m_device, *m_partition, m_newFirstSector, m_newLastSector );
op.setStatus( Operation::StatusRunning );
connect( &op, &Operation::progress, this, &ResizePartitionJob::iprogress );
QString errorMessage = tr( "The installer failed to resize partition %1 on disk '%2'." )
return KPMHelpers::execute( op,
tr( "The installer failed to resize partition %1 on disk '%2'." )
.arg( m_partition->partitionPath() )
.arg( m_device->name() );
if ( op.execute( report ) )
{
return Calamares::JobResult::ok();
}
return Calamares::JobResult::error( errorMessage, report.toText() );
.arg( m_device->name() ) );
}
void

View File

@ -13,6 +13,8 @@
#include "SetPartitionFlagsJob.h"
#include "core/KPMHelpers.h"
#include "partition/FileSystem.h"
#include "utils/Logger.h"
#include "utils/Units.h"
@ -148,17 +150,8 @@ SetPartFlagsJob::exec()
cDebug() << "Setting flags on" << m_device->deviceNode() << "partition" << partition()->deviceNode()
<< Logger::DebugList( flagsList );
Report report( nullptr );
SetPartFlagsOperation op( *m_device, *partition(), m_flags );
op.setStatus( Operation::StatusRunning );
connect( &op, &Operation::progress, this, &SetPartFlagsJob::iprogress );
QString errorMessage
= tr( "The installer failed to set flags on partition %1." ).arg( m_partition->partitionPath() );
if ( op.execute( report ) )
{
return Calamares::JobResult::ok();
}
return Calamares::JobResult::error( errorMessage, report.toText() );
return KPMHelpers::execute(
op, tr( "The installer failed to set flags on partition %1." ).arg( m_partition->partitionPath() ) );
}