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); mountPoint = FileSystem::detectMountPoint(fs, lvPath);
mounted = FileSystem::detectMountStatus(fs, lvPath); mounted = FileSystem::detectMountStatus(fs, lvPath);
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint); if (mountPoint != QString()) {
if (logicalSize() > 0 && fs->type() != FileSystem::Luks) { const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
if (mounted && freeSpaceInfo.isValid() && mountPoint != QString()) { if (logicalSize() > 0 && fs->type() != FileSystem::Luks)
fs->setSectorsUsed(freeSpaceInfo.used() / logicalSize()); if (mounted && freeSpaceInfo.isValid() && mountPoint != QString())
} else if (fs->supportGetUsed() == FileSystem::cmdSupportFileSystem) { fs->setSectorsUsed(freeSpaceInfo.used() / logicalSize());
fs->setSectorsUsed(qCeil(fs->readUsedCapacity(lvPath) / static_cast<float>(logicalSize())));
}
} }
else if (fs->supportGetUsed() == FileSystem::cmdSupportFileSystem)
fs->setSectorsUsed(qCeil(fs->readUsedCapacity(lvPath) / static_cast<float>(logicalSize())));
} }
if (fs->supportGetLabel() != FileSystem::cmdSupportNone) { 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) 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()) if (p.isMounted() && freeSpaceInfo.isValid() && mountPoint != QString())
p.fileSystem().setSectorsUsed(freeSpaceInfo.used() / d.logicalSize()); p.fileSystem().setSectorsUsed(freeSpaceInfo.used() / d.logicalSize());
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem) else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem)
p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / d.logicalSize()); p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / d.logicalSize());
}
#if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT #if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportCore) else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportCore)
p.fileSystem().setSectorsUsed(readSectorsUsedLibParted(pedDisk, p)); p.fileSystem().setSectorsUsed(readSectorsUsedLibParted(pedDisk, p));