Port away from KDiskFreeSpaceInfo to QStorageInfo.

This commit is contained in:
Andrius Štikonas 2017-09-08 18:35:30 +01:00
parent 1889b9e8fa
commit 2404689dd0
2 changed files with 5 additions and 7 deletions

View File

@ -34,7 +34,7 @@ set (pmlibpartedbackendplugin_SRCS
add_library(pmlibpartedbackendplugin SHARED ${pmlibpartedbackendplugin_SRCS})
target_link_libraries(pmlibpartedbackendplugin kpmcore ${LIBPARTED_LIBS} KF5::KIOCore KF5::I18n)
target_link_libraries(pmlibpartedbackendplugin kpmcore ${LIBPARTED_LIBS} KF5::I18n)
install(TARGETS pmlibpartedbackendplugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
kcoreaddons_desktop_to_json(pmlibpartedbackendplugin pmlibpartedbackendplugin.desktop DEFAULT_SERVICE_TYPE)

View File

@ -49,11 +49,11 @@
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QStorageInfo>
#include <QString>
#include <QStringList>
#include <KLocalizedString>
#include <KDiskFreeSpaceInfo>
#include <KPluginFactory>
#include <parted/parted.h>
@ -198,11 +198,9 @@ static qint64 readSectorsUsedLibParted(PedDisk* pedDisk, const Partition& p)
static void readSectorsUsed(PedDisk* pedDisk, const Device& d, Partition& p, const QString& mountPoint)
{
if (!mountPoint.isEmpty() && p.fileSystem().type() != FileSystem::LinuxSwap && p.fileSystem().type() != FileSystem::Lvm2_PV) {
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
// KDiskFreeSpaceInfo does not work with swap
if (p.isMounted() && freeSpaceInfo.isValid())
p.fileSystem().setSectorsUsed(freeSpaceInfo.used() / d.logicalSize());
const QStorageInfo storage = QStorageInfo(mountPoint);
if (p.isMounted() && storage.isValid())
p.fileSystem().setSectorsUsed( (storage.bytesTotal() - storage.bytesFree()) / d.logicalSize());
}
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem)
p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / d.logicalSize());