Browse Source

Improve used space detection to use fs utils when not mounted.

3.2
Andrius Štikonas 4 years ago
parent
commit
f8ba25fdfa
3 changed files with 8 additions and 8 deletions
  1. +2
    -2
      src/fs/luks.cpp
  2. +5
    -5
      src/plugins/libparted/libpartedbackend.cpp
  3. +1
    -1
      src/util/helpers.cpp

+ 2
- 2
src/fs/luks.cpp View File

@ -1,6 +1,6 @@
/*************************************************************************
* Copyright (C) 2012 by Volker Lanz <vl@fidra.de> *
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
* Copyright (C) 2013-2017 by Andrius Štikonas <andrius@stikonas.eu> *
* Copyright (C) 2015-2016 by Teo Mrnjavac <teo@kde.org> *
* *
* 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;


+ 5
- 5
src/plugins/libparted/libpartedbackend.cpp View File

@ -1,7 +1,7 @@
/*************************************************************************
* Copyright (C) 2008-2012 by Volker Lanz <vl@fidra.de> *
* Copyright (C) 2015-2016 by Teo Mrnjavac <teo@kde.org> *
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
* Copyright (C) 2016-2017 by Andrius Štikonas <andrius@stikonas.eu> *
* *
* 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));


+ 1
- 1
src/util/helpers.cpp View File

@ -89,7 +89,7 @@ KAboutData aboutKPMcore()
KAboutData aboutData( QStringLiteral("kpmcore"),
xi18nc("@title", "<application>KPMcore</application>"), QStringLiteral(VERSION),
xi18nc("@title", "Library for managing partitions"),
KAboutLicense::GPL_V3, xi18nc("@info:credit", "&copy; 2008-2016 KPMcore developers" ) );
KAboutLicense::GPL_V3, xi18nc("@info:credit", "&copy; 2008-2017 KPMcore developers" ) );
aboutData.setOrganizationDomain(QByteArray("kde.org"));
aboutData.setProductName(QByteArray("kpmcore"));
aboutData.setHomepage(QStringLiteral("https://commits.kde.org/kpmcore"));


Loading…
Cancel
Save