Merge pull request #1119 from cjlcarvalho/master

[partition] Fixing LVM scanning according to new kpmcore API
This commit is contained in:
Adriaan de Groot 2019-04-12 11:03:03 +02:00 committed by GitHub
commit 9917bc27fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 16 deletions

View File

@ -11,6 +11,7 @@ Andrius Štikonas
Bernhard Landauer
Bezzy1999
bill-auger
Caio Jordão Carvalho
crispg72
demmm
Gabriel Craciunescu

View File

@ -55,6 +55,7 @@
#include <kpmcore/core/device.h>
#include <kpmcore/core/lvmdevice.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/core/volumemanagerdevice.h>
#include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackendmanager.h>
#include <kpmcore/fs/filesystemfactory.h>
@ -550,26 +551,22 @@ PartitionCoreModule::lvmPVs() const
bool
PartitionCoreModule::hasVGwithThisName( const QString& name ) const
{
for ( DeviceInfo* d : m_deviceInfos )
if ( dynamic_cast<LvmDevice*>(d->device.data()) &&
d->device.data()->name() == name)
return true;
auto condition = [ name ]( DeviceInfo* d ) {
return dynamic_cast<LvmDevice*>(d->device.data()) && d->device.data()->name() == name;
};
return false;
return std::find_if( m_deviceInfos.begin(), m_deviceInfos.end(), condition ) != m_deviceInfos.end();
}
bool
PartitionCoreModule::isInVG( const Partition *partition ) const
{
for ( DeviceInfo* d : m_deviceInfos )
{
auto condition = [ partition ]( DeviceInfo* d ) {
LvmDevice* vg = dynamic_cast<LvmDevice*>( d->device.data());
return vg && vg->physicalVolumes().contains( partition );
};
if ( vg && vg->physicalVolumes().contains( partition ))
return true;
}
return false;
return std::find_if( m_deviceInfos.begin(), m_deviceInfos.end(), condition ) != m_deviceInfos.end();
}
void
@ -686,12 +683,13 @@ PartitionCoreModule::scanForLVMPVs()
}
}
// Update LVM::pvList
LvmDevice::scanSystemLVM( physicalDevices );
#ifdef WITH_KPMCOREGT33
VolumeManagerDevice::scanDevices( physicalDevices );
for ( auto p : LVM::pvList::list() )
#else
LvmDevice::scanSystemLVM( physicalDevices );
for ( auto p : LVM::pvList )
#endif
{