Commit 3ed42e88 authored by Nicolas Fella's avatar Nicolas Fella

Use mount point returned from DBus instead of using property value

Summary:
There is a slight time frame (~2ms) where mount has returned but the MountPoints property is not updated. When the mounpoint is queried during that time it will be empty and opening a plugged in USB device in Dolphin will fail.
To avoid this use the mountpoint information returned by the mount() call

Reviewers: broulik

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D20433
parent 48e823fb
......@@ -32,7 +32,7 @@
using namespace Solid::Backends::UDisks2;
StorageAccess::StorageAccess(Device *device)
: DeviceInterface(device), m_setupInProgress(false), m_teardownInProgress(false), m_passphraseRequested(false)
: DeviceInterface(device), m_setupInProgress(false), m_teardownInProgress(false), m_passphraseRequested(false), m_mountPoint()
{
connect(device, SIGNAL(changed()), this, SLOT(checkAccessibility()));
updateCache();
......@@ -79,29 +79,14 @@ bool StorageAccess::isAccessible() const
QString StorageAccess::filePath() const
{
QByteArrayList mntPoints;
if (isLuksDevice()) { // encrypted (and unlocked) device
const QString path = clearTextPath();
if (path.isEmpty() || path == "/") {
return QString();
}
Device holderDevice(path);
mntPoints = qdbus_cast<QByteArrayList>(holderDevice.prop("MountPoints"));
if (m_mountPoint.isEmpty()) {
QByteArrayList mntPoints = qdbus_cast<QByteArrayList>(m_device->prop("MountPoints"));
if (!mntPoints.isEmpty()) {
return QFile::decodeName(mntPoints.first()); // FIXME Solid doesn't support multiple mount points
} else {
return QString();
m_mountPoint = QFile::decodeName(mntPoints.first()); // FIXME Solid doesn't support multiple mount points
}
}
mntPoints = qdbus_cast<QByteArrayList>(m_device->prop("MountPoints"));
if (!mntPoints.isEmpty()) {
return QFile::decodeName(mntPoints.first()); // FIXME Solid doesn't support multiple mount points
} else {
return QString();
}
return m_mountPoint;
}
bool StorageAccess::isIgnored() const
......@@ -159,14 +144,25 @@ void StorageAccess::checkAccessibility()
}
}
void StorageAccess::slotDBusReply(const QDBusMessage & /*reply*/)
void StorageAccess::slotDBusReply(const QDBusMessage &reply)
{
if (m_setupInProgress) {
if (isLuksDevice() && !isAccessible()) { // unlocked device, now mount it
mount();
if (isLuksDevice()) {
if(!isAccessible()) { // unlocked device, now mount it
mount();
} else {
const QString path = clearTextPath();
if (path.isEmpty() || path == "/") {
return;
}
Device holderDevice(path);
QByteArrayList mntPoints = qdbus_cast<QByteArrayList>(holderDevice.prop("MountPoints"));
m_mountPoint = QFile::decodeName(mntPoints.first()); // FIXME Solid doesn't support multiple mount points
}
} else { // Don't broadcast setupDone unless the setup is really done. (Fix kde#271156)
m_setupInProgress = false;
m_device->invalidateCache();
m_mountPoint = reply.arguments().first().toString(); // FIXME Solid doesn't support multiple mount points
m_device->broadcastActionDone("setup");
checkAccessibility();
......
......@@ -94,6 +94,7 @@ private:
bool m_teardownInProgress;
bool m_passphraseRequested;
QString m_lastReturnObject;
mutable QString m_mountPoint;
static const int s_unmountTimeout = 0x7fffffff;
};
......
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