Skip to content

Commit

Permalink
Change objectPath internals to devicePath based
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Sep 19, 2018
1 parent 880055f commit 8afa0c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
9 changes: 5 additions & 4 deletions src/partitionmanager.cpp
Expand Up @@ -327,12 +327,13 @@ void PartitionManagerPrivate::format(const QString &devicePath, const QString &t
}
}

QString PartitionManagerPrivate::objectPath(const Partition &partition) const
QString PartitionManagerPrivate::objectPath(const QString &devicePath) const
{
if (externalMedia.match(partition.deviceName()).hasMatch()) {
return m_udisksMonitor->instance()->objectPath(partition.devicePath());
QString deviceName = devicePath.section(QChar('/'), 2);
if (externalMedia.match(deviceName).hasMatch()) {
return m_udisksMonitor->instance()->objectPath(devicePath);
} else {
qCWarning(lcMemoryCardLog) << "Object path existing only for external memory cards:" << partition.devicePath();
qCWarning(lcMemoryCardLog) << "Object path existing only for external memory cards:" << devicePath;
return QString();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/partitionmanager_p.h
Expand Up @@ -72,7 +72,7 @@ class PartitionManagerPrivate : public QObject, public QSharedData
void unmount(const Partition &partition);
void format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase);

QString objectPath(const Partition &partition) const;
QString objectPath(const QString &devicePath) const;

QStringList supportedFileSystems() const;

Expand Down
7 changes: 1 addition & 6 deletions src/partitionmodel.cpp
Expand Up @@ -168,12 +168,7 @@ void PartitionModel::format(const QString &devicePath, const QString &type, cons
QString PartitionModel::objectPath(const QString &devicePath) const
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << devicePath;
if (const Partition *partition = getPartition(devicePath)) {
return m_manager->objectPath(*partition);
} else {
qCWarning(lcMemoryCardLog) << "Unable to get object path for unknown device:" << devicePath;
return QString();
}
return m_manager->objectPath(devicePath);
}

void PartitionModel::update()
Expand Down

0 comments on commit 8afa0c3

Please sign in to comment.