Commit 4ce4dfb4 authored by sage's avatar sage

Merge branch 'jb40595' into 'master'

Jb40595

See merge request mer-core/nemo-qml-plugin-systemsettings!48
parents 1265d6f3 d771a072
...@@ -39,9 +39,7 @@ ...@@ -39,9 +39,7 @@
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusMessage> #include <QDBusMessage>
#include <QDBusReply> #include <QDBusReply>
#include <QStorageInfo>
#include <sys/statvfs.h>
quint64 DiskUsageWorker::calculateSize(QString directory, QString *expandedPath, bool androidHomeExists) quint64 DiskUsageWorker::calculateSize(QString directory, QString *expandedPath, bool androidHomeExists)
{ {
...@@ -61,18 +59,7 @@ quint64 DiskUsageWorker::calculateSize(QString directory, QString *expandedPath, ...@@ -61,18 +59,7 @@ quint64 DiskUsageWorker::calculateSize(QString directory, QString *expandedPath,
} }
if (directory == "/") { if (directory == "/") {
// Shortcut for getting usage of rootfs return QStorageInfo::root().bytesTotal() - QStorageInfo::root().bytesAvailable();
// TODO: Once we have Qt 5.4, use QStorageInfo
struct statvfs stv;
memset(&stv, 0, sizeof(stv));
if (statvfs(directory.toUtf8().constData(), &stv) != 0) {
// Do not make an entry for the usage here
qWarning() << "statvfs() failed on:" << directory;
return 0L;
}
quint64 fsSize = float(stv.f_frsize) * float(stv.f_blocks);
quint64 freeSpace = float(stv.f_frsize) * float(stv.f_bfree);
return fsSize - freeSpace;
} }
QDir d(directory); QDir d(directory);
...@@ -81,7 +68,7 @@ quint64 DiskUsageWorker::calculateSize(QString directory, QString *expandedPath, ...@@ -81,7 +68,7 @@ quint64 DiskUsageWorker::calculateSize(QString directory, QString *expandedPath,
} }
QProcess du; QProcess du;
du.start("du", QStringList() << "-sb" << directory, QIODevice::ReadOnly); du.start("du", QStringList() << "-sbx" << directory, QIODevice::ReadOnly);
du.waitForFinished(); du.waitForFinished();
if (du.exitStatus() != QProcess::NormalExit) { if (du.exitStatus() != QProcess::NormalExit) {
qWarning() << "Could not determine size of:" << directory; qWarning() << "Could not determine size of:" << directory;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment