Commit 880055f6 authored by Raine Makelainen's avatar Raine Makelainen

Make formatting devicePath based

parent 1796c15c
......@@ -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";
}
}
......
......@@ -70,7 +70,7 @@ public:
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;
......
......@@ -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
......
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