From ecdd09edcd1a46a8cd4190038e5b211877d87280 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 21 Jun 2019 21:17:43 +0200 Subject: [PATCH] [partition] Refactor getting partitions from device - Split out into own function - Prepare for implementation that doesn't use external processes --- src/modules/partition/jobs/ClearMountsJob.cpp | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/modules/partition/jobs/ClearMountsJob.cpp b/src/modules/partition/jobs/ClearMountsJob.cpp index 51ecd5d09..3c06fc04d 100644 --- a/src/modules/partition/jobs/ClearMountsJob.cpp +++ b/src/modules/partition/jobs/ClearMountsJob.cpp @@ -60,14 +60,9 @@ ClearMountsJob::prettyStatusMessage() const } -Calamares::JobResult -ClearMountsJob::exec() +QStringList +getPartitionsForDevice( const QString& deviceName ) { - CalamaresUtils::Partition::Syncer s; - QStringList goodNews; - - QString deviceName = m_device->deviceNode().split( '/' ).last(); - QProcess process; process.setProgram( "sh" ); process.setArguments( { @@ -81,6 +76,21 @@ ClearMountsJob::exec() const QString partitions = process.readAllStandardOutput(); const QStringList partitionsList = partitions.simplified().split( ' ' ); + return partitionsList; +} + +Calamares::JobResult +ClearMountsJob::exec() +{ + CalamaresUtils::Partition::Syncer s; + + QString deviceName = m_device->deviceNode().split( '/' ).last(); + + QStringList goodNews; + QProcess process; + + QStringList partitionsList = getPartitionsForDevice( deviceName ); + // Build a list of partitions of type 82 (Linux swap / Solaris). // We then need to clear them just in case they contain something resumable from a // previous suspend-to-disk.