Do not call KDiskFreeSpaceInfo::freeSpaceInfo without a non-empty mount point.

This commit is contained in:
Andrius Štikonas 2016-11-05 20:29:31 +00:00
parent eb0c32e9dc
commit e3214a1b48
2 changed files with 14 additions and 12 deletions

View File

@ -139,14 +139,14 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl
mountPoint = FileSystem::detectMountPoint(fs, lvPath);
mounted = FileSystem::detectMountStatus(fs, lvPath);
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
if (logicalSize() > 0 && fs->type() != FileSystem::Luks) {
if (mounted && freeSpaceInfo.isValid() && mountPoint != QString()) {
fs->setSectorsUsed(freeSpaceInfo.used() / logicalSize());
} else if (fs->supportGetUsed() == FileSystem::cmdSupportFileSystem) {
fs->setSectorsUsed(qCeil(fs->readUsedCapacity(lvPath) / static_cast<float>(logicalSize())));
}
if (mountPoint != QString()) {
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
if (logicalSize() > 0 && fs->type() != FileSystem::Luks)
if (mounted && freeSpaceInfo.isValid() && mountPoint != QString())
fs->setSectorsUsed(freeSpaceInfo.used() / logicalSize());
}
else if (fs->supportGetUsed() == FileSystem::cmdSupportFileSystem)
fs->setSectorsUsed(qCeil(fs->readUsedCapacity(lvPath) / static_cast<float>(logicalSize())));
}
if (fs->supportGetLabel() != FileSystem::cmdSupportNone) {

View File

@ -194,12 +194,14 @@ static qint64 readSectorsUsedLibParted(PedDisk* pedDisk, const Partition& p)
*/
static void readSectorsUsed(PedDisk* pedDisk, const Device& d, Partition& p, const QString& mountPoint)
{
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
if (mountPoint != QString()) {
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
if (p.isMounted() && freeSpaceInfo.isValid() && mountPoint != QString())
p.fileSystem().setSectorsUsed(freeSpaceInfo.used() / d.logicalSize());
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem)
p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / d.logicalSize());
if (p.isMounted() && freeSpaceInfo.isValid() && mountPoint != QString())
p.fileSystem().setSectorsUsed(freeSpaceInfo.used() / d.logicalSize());
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem)
p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / d.logicalSize());
}
#if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportCore)
p.fileSystem().setSectorsUsed(readSectorsUsedLibParted(pedDisk, p));