Commit be3b80e7 authored by Oleg Solovyov's avatar Oleg Solovyov Committed by Kai Uwe Broulik

Plasmashell freezes when trying to get free space info from mounted remote...

Plasmashell freezes when trying to get free space info from mounted remote filesystem after losing connection to it

Summary:
BUG: 397537

Earlier plasmashell assumed that you'll get free space info immediately (which is not true in case of losing connection to server containing a mounted filesystem - statfs will wait for response forever and freeze everything since it's happening in main thread)

I moved obtaining that info into different thread so that case won't freeze anything anymore.
It creates exactly one thread per one path. If a path is already being processed, new thread won't be created.
Also I implemented a timer used to notify about broken connection after 15 seconds.

Reviewers: broulik, ngraham, davidedmundson

Reviewed By: broulik

Subscribers: ngraham, anthonyfieroni, davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D14895

Backported to 5.12 LTS (sans notification due to new strings) for impact to corporate setups
CCBUG: 399945

(cherry picked from commit e1c19ce4)
parent fc1e22ba
......@@ -25,8 +25,10 @@
#include <klocalizedstring.h>
#include <QDebug>
#include <KDiskFreeSpaceInfo>
#include <QUrl>
#include <KFormat>
#include <KIO/FileSystemFreeSpaceJob>
#include <Plasma/DataContainer>
......@@ -547,12 +549,25 @@ bool SolidDeviceEngine::updateStorageSpace(const QString &udi)
return false;
}
KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(storageaccess->filePath());
if (info.isValid()) {
setData(udi, I18N_NOOP("Free Space"), QVariant(info.available()));
setData(udi, I18N_NOOP("Free Space Text"), KFormat().formatByteSize(info.available()));
setData(udi, I18N_NOOP("Size"), QVariant(info.size()));
return true;
QString path = storageaccess->filePath();
if (!m_paths.contains(path)) {
m_paths.insert(path);
// create job
KIO::FileSystemFreeSpaceJob *job = KIO::fileSystemFreeSpace(QUrl::fromLocalFile(path));
// collect and process info
connect(job, &KIO::FileSystemFreeSpaceJob::result, this,
[this, path, udi](KIO::Job *job, KIO::filesize_t size, KIO::filesize_t available) {
if (!job->error()) {
setData(udi, I18N_NOOP("Free Space"), QVariant(available));
setData(udi, I18N_NOOP("Free Space Text"), KFormat().formatByteSize(available));
setData(udi, I18N_NOOP("Size"), QVariant(size));
}
m_paths.remove(path);
});
}
return false;
......
......@@ -80,6 +80,8 @@ private:
QMap<QString, Solid::Device> m_devicemap;
//udi, corresponding encrypted container udi;
QMap<QString, QString> m_encryptedContainerMap;
//path, for pending file system free space jobs
QSet<QString> m_paths;
DeviceSignalMapManager *m_signalmanager;
HddTemp *m_temperature;
......
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