From f8ba25fdfa637c52685a9f37447221a63166e381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Thu, 5 Jan 2017 17:27:17 +0000 Subject: [PATCH] Improve used space detection to use fs utils when not mounted. --- src/fs/luks.cpp | 4 ++-- src/plugins/libparted/libpartedbackend.cpp | 10 +++++----- src/util/helpers.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/fs/luks.cpp b/src/fs/luks.cpp index 59fe16d..3bdd190 100644 --- a/src/fs/luks.cpp +++ b/src/fs/luks.cpp @@ -1,6 +1,6 @@ /************************************************************************* * Copyright (C) 2012 by Volker Lanz * - * Copyright (C) 2013 by Andrius Štikonas * + * Copyright (C) 2013-2017 by Andrius Štikonas * * Copyright (C) 2015-2016 by Teo Mrnjavac * * * * This program is free software; you can redistribute it and/or * @@ -389,7 +389,7 @@ bool luks::mount(Report& report, const QString& deviceNode, const QString& mount m_isMounted = true; const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint); - if (freeSpaceInfo.isValid() && mountPoint != QString()) + if (freeSpaceInfo.isValid() && !mountPoint.isEmpty()) setSectorsUsed((freeSpaceInfo.used() + payloadOffset()) / m_logicalSectorSize); return true; diff --git a/src/plugins/libparted/libpartedbackend.cpp b/src/plugins/libparted/libpartedbackend.cpp index abc622b..bce45fb 100644 --- a/src/plugins/libparted/libpartedbackend.cpp +++ b/src/plugins/libparted/libpartedbackend.cpp @@ -1,7 +1,7 @@ /************************************************************************* * Copyright (C) 2008-2012 by Volker Lanz * * Copyright (C) 2015-2016 by Teo Mrnjavac * - * Copyright (C) 2016 by Andrius Štikonas * + * Copyright (C) 2016-2017 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -193,15 +193,15 @@ static qint64 readSectorsUsedLibParted(PedDisk* pedDisk, const Partition& p) */ static void readSectorsUsed(PedDisk* pedDisk, const Device& d, Partition& p, const QString& mountPoint) { - if (mountPoint != QString()) { + if (!mountPoint.isEmpty()) { const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint); // KDiskFreeSpaceInfo does not work with swap - if (p.isMounted() && freeSpaceInfo.isValid() && mountPoint != QString() && p.fileSystem().type() != FileSystem::LinuxSwap) + if (p.isMounted() && freeSpaceInfo.isValid() && p.fileSystem().type() != FileSystem::LinuxSwap) p.fileSystem().setSectorsUsed(freeSpaceInfo.used() / d.logicalSize()); - else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem) - p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / 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)); diff --git a/src/util/helpers.cpp b/src/util/helpers.cpp index 0c2b167..9e1c334 100644 --- a/src/util/helpers.cpp +++ b/src/util/helpers.cpp @@ -89,7 +89,7 @@ KAboutData aboutKPMcore() KAboutData aboutData( QStringLiteral("kpmcore"), xi18nc("@title", "KPMcore"), QStringLiteral(VERSION), xi18nc("@title", "Library for managing partitions"), - KAboutLicense::GPL_V3, xi18nc("@info:credit", "© 2008-2016 KPMcore developers" ) ); + KAboutLicense::GPL_V3, xi18nc("@info:credit", "© 2008-2017 KPMcore developers" ) ); aboutData.setOrganizationDomain(QByteArray("kde.org")); aboutData.setProductName(QByteArray("kpmcore")); aboutData.setHomepage(QStringLiteral("https://commits.kde.org/kpmcore"));