Skip to content

Commit

Permalink
Make formatting devicePath based
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Sep 19, 2018
1 parent 1796c15 commit 880055f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/partitionmanager.cpp
Expand Up @@ -316,14 +316,14 @@ void PartitionManagerPrivate::unmount(const Partition &partition)
}
}

void PartitionManagerPrivate::format(const Partition &partition, const QString &type, const QString &label, const QString &passphrase)
void PartitionManagerPrivate::format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase)
{
qCInfo(lcMemoryCardLog) << "Can format:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.devicePath();

if (externalMedia.match(partition.deviceName()).hasMatch()) {
m_udisksMonitor->instance()->format(partition.devicePath(), type, label, passphrase);
QString deviceName = devicePath.section(QChar('/'), 2);
qCInfo(lcMemoryCardLog) << "Can format:" << externalMedia.match(deviceName).hasMatch() << devicePath;
if (externalMedia.match(deviceName).hasMatch()) {
m_udisksMonitor->instance()->format(devicePath, type, label, passphrase);
} else {
qCWarning(lcMemoryCardLog) << "Formatting allowed only for external memory cards," << partition.devicePath() << "is not allowed";
qCWarning(lcMemoryCardLog) << "Formatting allowed only for external memory cards," << devicePath << "is not allowed";
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/partitionmanager_p.h
Expand Up @@ -70,7 +70,7 @@ class PartitionManagerPrivate : public QObject, public QSharedData
void unlock(const Partition &partition, const QString &passphrase);
void mount(const Partition &partition);
void unmount(const Partition &partition);
void format(const Partition &partition, const QString &type, const QString &label, const QString &passphrase);
void format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase);

QString objectPath(const Partition &partition) const;

Expand Down
6 changes: 1 addition & 5 deletions src/partitionmodel.cpp
Expand Up @@ -162,11 +162,7 @@ void PartitionModel::unmount(const QString &devicePath)
void PartitionModel::format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase)
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << devicePath << type << label << m_partitions.count();
if (const Partition *partition = getPartition(devicePath)) {
m_manager->format(*partition, type, label, passphrase);
} else {
qCWarning(lcMemoryCardLog) << "Unable to format unknown device:" << devicePath;
}
m_manager->format(devicePath, type, label, passphrase);
}

QString PartitionModel::objectPath(const QString &devicePath) const
Expand Down

0 comments on commit 880055f

Please sign in to comment.