From c5f9397d1821acdc8b51bb826791df3d4073c0d5 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 17 Sep 2015 15:14:18 +0200 Subject: [PATCH] Keep UUID when clearing swap. CAL-156 #comment I've just pushed a fix attempt for this, please test. --- src/modules/partition/jobs/ClearMountsJob.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/modules/partition/jobs/ClearMountsJob.cpp b/src/modules/partition/jobs/ClearMountsJob.cpp index 1a397b325..4e156945b 100644 --- a/src/modules/partition/jobs/ClearMountsJob.cpp +++ b/src/modules/partition/jobs/ClearMountsJob.cpp @@ -200,10 +200,17 @@ QString ClearMountsJob::tryClearSwap( const QString& partPath ) { QProcess process; - process.start( "mkswap", { partPath } ); + process.start( "blkid", { "-s", "UUID", "-o", "value", partPath } ); process.waitForFinished(); - if ( process.exitCode() == 0 ) - return QString( "Successfully cleared swap %1." ).arg( partPath ); + QString swapPartUuid = QString::fromLocal8Bit( process.readAllStandardOutput() ).simplified(); + if ( process.exitCode() != 0 || + swapPartUuid.isEmpty() ) + return QString(); - return QString(); + process.start( "mkswap", { "-U", swapPartUuid, partPath } ); + process.waitForFinished(); + if ( process.exitCode() != 0 ) + return QString(); + + return QString( "Successfully cleared swap %1." ).arg( partPath ); }