Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Commit 96af9a6

Browse files
committed
Merge branch 'jb47605' into 'master'
[nemo-systemsettings] Cleanup hardcoded nemo user. Fixes JB#47605 See merge request mer-core/nemo-qml-plugin-systemsettings!123
2 parents 2e04b05 + 1f91b5c commit 96af9a6

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/diskusage.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ QVariantMap DiskUsageWorker::calculate(QStringList paths)
9898
// Sort keys in reverse order (so child directories come before their
9999
// parents, and the calculation is done correctly, no child directory
100100
// subtracted once too often), for example:
101-
// 1. a0 = size(/home/nemo/foo/)
102-
// 2. b0 = size(/home/nemo/)
101+
// 1. a0 = size(/home/<user>/foo/)
102+
// 2. b0 = size(/home/<user>/)
103103
// 3. c0 = size(/)
104104
//
105105
// This will calculate the following changes in the nested for loop below:
@@ -113,9 +113,9 @@ QVariantMap DiskUsageWorker::calculate(QStringList paths)
113113
// 3. c' = c2 = c1 - b1 = (c0 - a0) - (b0 - a0) = c0 - a0 - b0 + a0 = c0 - b0
114114
//
115115
// Or with paths:
116-
// 1. output(/home/nemo/foo/) = size(/home/nemo/foo/)
117-
// 2. output(/home/nemo/) = size(/home/nemo/) - size(/home/nemo/foo/)
118-
// 3. output(/) = size(/) - size(/home/nemo/)
116+
// 1. output(/home/<user>/foo/) = size(/home/<user>/foo/)
117+
// 2. output(/home/<user>/) = size(/home/<user>/) - size(/home/<user>/foo/)
118+
// 3. output(/) = size(/) - size(/home/<user>/)
119119
QStringList keys;
120120
foreach (const QString &key, usage.uniqueKeys()) {
121121
keys << expandedPaths.value(key, key);

tests/ut_diskusage.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/*
3-
* Copyright (C) 2015 Jolla Ltd.
4-
* Contact: Thomas Perl <[email protected]>
3+
* Copyright (c) 2015 - 2019 Jolla Ltd.
4+
* Copyright (c) 2019 Open Mobile Platform LLC.
55
*
66
* You may use this file under the terms of the BSD license as follows:
77
*
@@ -37,7 +37,7 @@
3737
#include "ut_diskusage.h"
3838

3939
#include <QtTest>
40-
40+
#include <QDir>
4141

4242
static QVariantMap g_mocked_file_size;
4343
static QVariantMap g_mocked_rpm_size;
@@ -131,37 +131,37 @@ void Ut_DiskUsage::testSubtractNestedSubdirectory()
131131
{
132132
g_mocked_file_size["/"] = MB(1000);
133133
g_mocked_file_size["/home/"] = MB(300);
134-
g_mocked_file_size["/home/nemo/"] = MB(150);
135-
g_mocked_file_size["/home/nemo/Documents/"] = MB(70);
134+
g_mocked_file_size[QDir::homePath()] = MB(150);
135+
g_mocked_file_size[QDir::homePath() + "/Documents/"] = MB(70);
136136

137137
QVariantMap usage = DiskUsageWorker().calculate(QStringList() <<
138-
"/" << "/home/" << "/home/nemo/" << "/home/nemo/Documents/");
138+
"/" << "/home/" << QDir::homePath() << QDir::homePath() + "/Documents/");
139139

140140
UT_DISKUSAGE_EXPECT_SIZE("/", MB(1000) - MB(300))
141141
UT_DISKUSAGE_EXPECT_SIZE("/home/", MB(300) - MB(150))
142-
UT_DISKUSAGE_EXPECT_SIZE("/home/nemo/", MB(150) - MB(70))
143-
UT_DISKUSAGE_EXPECT_SIZE("/home/nemo/Documents/", MB(70))
142+
UT_DISKUSAGE_EXPECT_SIZE(QDir::homePath(), MB(150) - MB(70))
143+
UT_DISKUSAGE_EXPECT_SIZE(QDir::homePath() + "/Documents/", MB(70))
144144
}
145145

146146
void Ut_DiskUsage::testSubtractNestedSubdirectoryMulti()
147147
{
148148
g_mocked_file_size["/"] = MB(1000);
149149
g_mocked_file_size["/home/"] = MB(300);
150-
g_mocked_file_size["/home/nemo/"] = MB(150);
151-
g_mocked_file_size["/home/nemo/Documents/"] = MB(70);
150+
g_mocked_file_size[QDir::homePath()] = MB(150);
151+
g_mocked_file_size[QDir::homePath() + "/Documents/"] = MB(70);
152152
g_mocked_file_size["/opt/"] = MB(100);
153153
g_mocked_file_size["/opt/foo/"] = MB(30);
154154
g_mocked_file_size["/opt/foo/bar/"] = MB(20);
155155
g_mocked_file_size["/opt/baz/"] = MB(10);
156156

157157
QVariantMap usage = DiskUsageWorker().calculate(QStringList() << "/" <<
158-
"/home/" << "/home/nemo/" << "/home/nemo/Documents/" <<
158+
"/home/" << QDir::homePath() << QDir::homePath() + "/Documents/" <<
159159
"/opt/" << "/opt/foo/" << "/opt/foo/bar/" << "/opt/baz/");
160160

161161
UT_DISKUSAGE_EXPECT_SIZE("/", MB(1000) - MB(300) - MB(100))
162162
UT_DISKUSAGE_EXPECT_SIZE("/home/", MB(300) - MB(150))
163-
UT_DISKUSAGE_EXPECT_SIZE("/home/nemo/", MB(150) - MB(70))
164-
UT_DISKUSAGE_EXPECT_SIZE("/home/nemo/Documents/", MB(70))
163+
UT_DISKUSAGE_EXPECT_SIZE(QDir::homePath(), MB(150) - MB(70))
164+
UT_DISKUSAGE_EXPECT_SIZE(QDir::homePath() + "/Documents/", MB(70))
165165
UT_DISKUSAGE_EXPECT_SIZE("/opt/", MB(100) - MB(30) - MB(10))
166166
UT_DISKUSAGE_EXPECT_SIZE("/opt/foo/", MB(30) - MB(20))
167167
UT_DISKUSAGE_EXPECT_SIZE("/opt/foo/bar/", MB(20))

0 commit comments

Comments
 (0)