File indexing completed on 2024-04-28 05:45:54
0001 /* 0002 SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com> 0003 SPDX-FileCopyrightText: 2016 Andrius Štikonas <andrius@stikonas.eu> 0004 0005 SPDX-License-Identifier: GPL-3.0-or-later 0006 */ 0007 0008 #include "jobs/movephysicalvolumejob.h" 0009 0010 #include "core/lvmdevice.h" 0011 0012 #include "util/report.h" 0013 0014 #include <KLocalizedString> 0015 0016 /** Creates a new MovePhysicalVolumeJob 0017 * @param d Device representing LVM Volume Group 0018 */ 0019 MovePhysicalVolumeJob::MovePhysicalVolumeJob(LvmDevice& d, const QList <const Partition*>& partList) : 0020 Job(), 0021 m_Device(d), 0022 m_PartList(partList) 0023 { 0024 } 0025 0026 bool MovePhysicalVolumeJob::run(Report& parent) 0027 { 0028 bool rval = false; 0029 0030 Report* report = jobStarted(parent); 0031 0032 QStringList destinations = device().deviceNodes(); 0033 for (const auto &p : partList()) { 0034 if (destinations.contains(p->partitionPath())) { 0035 destinations.removeAll(p->partitionPath()); 0036 } 0037 } 0038 0039 for (const auto &p : partList()) { 0040 rval = LvmDevice::movePV(*report, p->partitionPath(), destinations); 0041 if (rval == false) { 0042 break; 0043 } 0044 } 0045 0046 jobFinished(*report, rval); 0047 0048 return rval; 0049 } 0050 0051 QString MovePhysicalVolumeJob::description() const 0052 { 0053 QString movedPartitions = QString(); 0054 for (const auto &p : partList()) 0055 movedPartitions += p->deviceNode() + QStringLiteral(", "); 0056 movedPartitions.chop(2); 0057 return xi18nc("@info/plain", "Move used PE in %1 on %2 to other available Physical Volumes", movedPartitions, device().name()); 0058 }