From ee49c05d600da002ad24ee2be11338defe48b282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 7 Nov 2016 18:56:26 +0000 Subject: [PATCH] Remove ResizeVolumeGroup operation from operation stack if it has no jobs. --- src/core/operationstack.cpp | 17 +++++++++++++++++ src/core/operationstack.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/core/operationstack.cpp b/src/core/operationstack.cpp index cfb54ad..a7a975e 100644 --- a/src/core/operationstack.cpp +++ b/src/core/operationstack.cpp @@ -31,6 +31,7 @@ #include "ops/setpartflagsoperation.h" #include "ops/setfilesystemlabeloperation.h" #include "ops/createpartitiontableoperation.h" +#include "ops/resizevolumegroupoperation.h" #include "ops/checkoperation.h" #include "jobs/setfilesystemlabeljob.h" @@ -395,6 +396,19 @@ bool OperationStack::mergeCreatePartitionTableOperation(Operation*& currentOp, O return false; } +bool OperationStack::mergeResizeVolumeGroupResizeOperation(Operation*& pushedOp) +{ + ResizeVolumeGroupOperation* pushedResizeVolumeGroupOp = dynamic_cast(pushedOp); + + if (pushedResizeVolumeGroupOp && pushedResizeVolumeGroupOp->jobs().count() == 0) { + Log() << xi18nc("@info:status", "Resizing Volume Group, nothing to do."); + + return true; + } + + return false; +} + /** Pushes a new Operation on the OperationStack. This method will call all methods that try to merge the new Operation with the @@ -408,6 +422,9 @@ void OperationStack::push(Operation* o) { Q_ASSERT(o); + if (mergeResizeVolumeGroupResizeOperation(o)) + return; + for (auto currentOp = operations().rbegin(); currentOp != operations().rend(); ++currentOp) { if (mergeNewOperation(*currentOp, o)) break; diff --git a/src/core/operationstack.h b/src/core/operationstack.h index b6fbfac..2a8d098 100644 --- a/src/core/operationstack.h +++ b/src/core/operationstack.h @@ -98,6 +98,7 @@ protected: bool mergePartFlagsOperation(Operation*& currentOp, Operation*& pushedOp); bool mergePartLabelOperation(Operation*& currentOp, Operation*& pushedOp); bool mergeCreatePartitionTableOperation(Operation*& currentOp, Operation*& pushedOp); + bool mergeResizeVolumeGroupResizeOperation(Operation*& pushedOp); private: Operations m_Operations;