Port unmount code away from KMountPoints (KIO).

This commit is contained in:
Andrius Štikonas 2017-09-08 17:58:27 +01:00
parent f1accd1e0d
commit 1889b9e8fa
1 changed files with 10 additions and 9 deletions

View File

@ -29,12 +29,12 @@
#include "util/report.h" #include "util/report.h"
#include <QRegularExpression> #include <QRegularExpression>
#include <QStorageInfo>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QTextStream> #include <QTextStream>
#include <KLocalizedString> #include <KLocalizedString>
#include <KIOCore/KMountPoint>
/** Creates a new Partition object. /** Creates a new Partition object.
@param parent the Partition's parent. May be another Partition (for logicals) or a PartitionTable. Must not be nullptr. @param parent the Partition's parent. May be another Partition (for logicals) or a PartitionTable. Must not be nullptr.
@ -326,17 +326,18 @@ bool Partition::unmount(Report& report)
if (!isMounted()) if (!isMounted())
return false; return false;
bool success = true; bool success = false;
while (success) { if (fileSystem().canUnmount(deviceNode())) {
if (fileSystem().canUnmount(deviceNode())) { success = fileSystem().unmount(report, deviceNode());
success = fileSystem().unmount(report, deviceNode()); }
}
KMountPoint::List mountPoints = KMountPoint::currentMountPoints(KMountPoint::NeedRealDeviceName); const QList<QStorageInfo> mountedVolumes = QStorageInfo::mountedVolumes();
for (const QStorageInfo &storage : QStorageInfo::mountedVolumes()) {
if (!mountPoints.findByDevice(deviceNode())) if (QString::fromUtf8(storage.device()) == deviceNode() ) {
success = false;
break; break;
}
} }
setMounted(!success); setMounted(!success);