┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/viewproperties.cpp
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2018-09-17 16:02:50 +0200
committerKai Uwe Broulik <[email protected]>2018-09-17 16:02:50 +0200
commit7ec783e7493a3c6a8d40a01d49e930b7ae5520f8 (patch)
tree192d903ae8602788e4f4d1fac74f8841a43adaa4 /src/views/viewproperties.cpp
parentcb6c71ae1b7e2a19c876608e375f7ba7068977a3 (diff)
[ViewProperties] Check part of home first before doing file system stuff
There's no point in creating a QFileInfo instance and checking for file properties if we're not going to do anything with it when not inside home. Differential Revision: https://phabricator.kde.org/D15237
Diffstat (limited to 'src/views/viewproperties.cpp')
-rw-r--r--src/views/viewproperties.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp
index e5d636cd1..d7c6abd65 100644
--- a/src/views/viewproperties.cpp
+++ b/src/views/viewproperties.cpp
@@ -63,17 +63,19 @@ ViewProperties::ViewProperties(const QUrl& url) :
useDetailsViewWithPath = true;
} else if (url.isLocalFile()) {
m_filePath = url.toLocalFile();
- const QFileInfo dirInfo(m_filePath);
- const QFileInfo fileInfo(m_filePath + QDir::separator() + ViewPropertiesFileName);
- // Check if the directory is writable and check if the ".directory" file exists and
- // is read- and writable.
- if (!dirInfo.isWritable()
- || (fileInfo.exists() && !(fileInfo.isReadable() && fileInfo.isWritable()))
- || !isPartOfHome(m_filePath)) {
-#ifdef Q_OS_WIN
- // m_filePath probably begins with C:/ - the colon is not a valid character for paths though
- m_filePath = QDir::separator() + m_filePath.remove(QLatin1Char(':'));
-#endif
+
+ bool useDestinationDir = !isPartOfHome(m_filePath);
+ if (!useDestinationDir) {
+ const QFileInfo dirInfo(m_filePath);
+ const QFileInfo fileInfo(m_filePath + QDir::separator() + ViewPropertiesFileName);
+ useDestinationDir = !dirInfo.isWritable() || (dirInfo.size() > 0 && fileInfo.exists() && !(fileInfo.isReadable() && fileInfo.isWritable()));
+ }
+
+ if (useDestinationDir) {
+ #ifdef Q_OS_WIN
+ // m_filePath probably begins with C:/ - the colon is not a valid character for paths though
+ m_filePath = QDir::separator() + m_filePath.remove(QLatin1Char(':'));
+ #endif
m_filePath = destinationDir(QStringLiteral("local")) + m_filePath;
}
} else {