Commit 24255e92 authored by David Redondo's avatar David Redondo 🏎
Browse files

Also convert /partitions/all to disk/all

parent f287e60a
...@@ -91,6 +91,18 @@ private Q_SLOTS: ...@@ -91,6 +91,18 @@ private Q_SLOTS:
{newPrefix + QStringLiteral("/used")}, {newPrefix + QStringLiteral("/used")},
}; };
} }
QTest::addRow("paritionsall")
<< QJsonArray {
QStringLiteral("partitions/all/total"),
QStringLiteral("partitions/all/freespace"),
QStringLiteral("partitions/all/filllevel"),
QStringLiteral("partitions/all/usedspace"),
} << QJsonArray {
QStringLiteral("disk/all/total"),
QStringLiteral("disk/all/free"),
QStringLiteral("disk/all/usedPercent"),
QStringLiteral("disk/all/used"),
};
} }
void testSensorIdConversion() void testSensorIdConversion()
{ {
......
...@@ -192,13 +192,18 @@ QString SensorFaceControllerPrivate::replacePartitionId(const QString &entryName ...@@ -192,13 +192,18 @@ QString SensorFaceControllerPrivate::replacePartitionId(const QString &entryName
if (!match.hasMatch()) { if (!match.hasMatch()) {
return entryName; return entryName;
} }
QString sensorId = entryName;
if (match.captured(1) == QLatin1String("/all")) {
return sensorId.replace(match.captured(0), QStringLiteral("disk/all/"));
}
const QString filePath = match.captured(1) == QLatin1String("/__root__") ? QStringLiteral("/") : match.captured(1); const QString filePath = match.captured(1) == QLatin1String("/__root__") ? QStringLiteral("/") : match.captured(1);
const Solid::Predicate predicate(Solid::DeviceInterface::StorageAccess, QStringLiteral("filePath"), filePath); const Solid::Predicate predicate(Solid::DeviceInterface::StorageAccess, QStringLiteral("filePath"), filePath);
const auto devices = Solid::Device::listFromQuery(predicate); const auto devices = Solid::Device::listFromQuery(predicate);
if (devices.empty()) { if (devices.empty()) {
return entryName; return entryName;
} }
QString sensorId = entryName;
const auto volume = devices[0].as<Solid::StorageVolume>(); const auto volume = devices[0].as<Solid::StorageVolume>();
const QString id = volume->uuid().isEmpty() ? volume->label() : volume->uuid(); const QString id = volume->uuid().isEmpty() ? volume->label() : volume->uuid();
return sensorId.replace(match.captured(0), QStringLiteral("disk/%1/").arg(id)); return sensorId.replace(match.captured(0), QStringLiteral("disk/%1/").arg(id));
......
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