Improve checking whether LVM VG can be removed.
E.g. if we remove all LVM LVs without applying operations then LVM VG removal should be possible. This still does not take into account inactive LVM volumes.
This commit is contained in:
parent
5c2d485b32
commit
eb0c32e9dc
|
@ -18,6 +18,7 @@
|
|||
#include "ops/removevolumegroupoperation.h"
|
||||
#include "jobs/removevolumegroupjob.h"
|
||||
|
||||
#include "core/partition.h"
|
||||
#include "core/partitiontable.h"
|
||||
#include "core/volumemanagerdevice.h"
|
||||
|
||||
|
@ -50,3 +51,24 @@ void RemoveVolumeGroupOperation::undo()
|
|||
{
|
||||
device().setPartitionTable(m_PartitionTable);
|
||||
}
|
||||
|
||||
/** Check if Volume Group can be safely removed
|
||||
*
|
||||
* @param dev VolumeManagerDevice with initialized partitions
|
||||
* @return true if there are no LVM partitions.
|
||||
*/
|
||||
bool RemoveVolumeGroupOperation::isRemovable(const VolumeManagerDevice* dev)
|
||||
{
|
||||
// TODO: allow removal when LVs are inactive.
|
||||
if (dev->type() == Device::LVM_Device) {
|
||||
if (dev->partitionTable()->children().count() == 0) // This is necessary to prevent a crash during applying of operations
|
||||
return true;
|
||||
else if (dev->partitionTable()->children().count() > 1)
|
||||
return false;
|
||||
else
|
||||
if (dev->partitionTable()->children().first()->fileSystem().type() == FileSystem::Unknown)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ public:
|
|||
virtual void preview() override;
|
||||
virtual void undo() override;
|
||||
|
||||
static bool isRemovable(const VolumeManagerDevice* dev);
|
||||
|
||||
protected:
|
||||
RemoveVolumeGroupJob* removeVolumeGroupJob() {
|
||||
return m_RemoveVolumeGroupJob;
|
||||
|
|
Loading…
Reference in New Issue