Commit d407c83a authored by Robert Hoffmann's avatar Robert Hoffmann
Browse files

Network mounts performance optimizations

This patch is part of performance optimizations for mounted network shares,
see also kcoreaddons, kio, kconfigwidgets, kwidgetsaddons, ktexteditor, dolphin.

It can speed up the start of Kate and opening documents when operating on
slow network drives.
parent 0b483077
Pipeline #72175 passed with stage
in 6 minutes and 7 seconds
......@@ -17,6 +17,11 @@
#include <KConfigGroup>
#include <KLocalizedString>
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 85, 0)
#include <KNetworkMounts>
#endif
#include <KSharedConfig>
#include <QCoreApplication>
......@@ -249,7 +254,11 @@ bool KateProjectPlugin::closeProject(KateProject *project)
KateProject *KateProjectPlugin::projectForUrl(const QUrl &url)
{
if (url.isEmpty() || !url.isLocalFile()) {
if (url.isEmpty() || !url.isLocalFile()
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 85, 0)
|| KNetworkMounts::self()->isOptionEnabledForPath(url.toLocalFile(), KNetworkMounts::MediumSideEffectsOptimizations)
#endif
) {
return nullptr;
}
......
......@@ -13,6 +13,11 @@
#include <KConfigGui>
#include <KLocalizedString>
#include <KMessageBox>
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 85, 0)
#include <KNetworkMounts>
#endif
#include <KSharedConfig>
#include <KStartupInfo>
#include <KWindowInfo>
......@@ -222,7 +227,11 @@ bool KateApp::startupKate()
UrlInfo info(positionalArgument);
// this file is no local dir, open it, else warn
bool noDir = !info.url.isLocalFile() || !QFileInfo(info.url.toLocalFile()).isDir();
bool noDir = !info.url.isLocalFile()
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 85, 0)
|| KNetworkMounts::self()->isOptionEnabledForPath(info.url.toLocalFile(), KNetworkMounts::LowSideEffectsOptimizations)
#endif
|| !QFileInfo(info.url.toLocalFile()).isDir();
if (noDir) {
doc = openDocUrl(info.url, codec_name, tempfileSet);
......@@ -327,7 +336,11 @@ KTextEditor::Document *KateApp::openDocUrl(const QUrl &url, const QString &encod
QTextCodec *codec = encoding.isEmpty() ? nullptr : QTextCodec::codecForName(encoding.toLatin1());
// this file is no local dir, open it, else warn
bool noDir = !url.isLocalFile() || !QFileInfo(url.toLocalFile()).isDir();
bool noDir = !url.isLocalFile()
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 85, 0)
|| KNetworkMounts::self()->isOptionEnabledForPath(url.toLocalFile(), KNetworkMounts::LowSideEffectsOptimizations)
#endif
|| !QFileInfo(url.toLocalFile()).isDir();
KTextEditor::Document *doc = nullptr;
......
......@@ -23,6 +23,10 @@
#include <KLocalizedString>
#include <KMessageBox>
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 85, 0)
#include <KNetworkMounts>
#endif
#include <QApplication>
#include <QFileDialog>
#include <QProgressDialog>
......@@ -110,7 +114,11 @@ KateDocumentInfo *KateDocManager::documentInfo(KTextEditor::Document *doc)
static QUrl normalizeUrl(const QUrl &url)
{
// Resolve symbolic links for local files (done anyway in KTextEditor)
if (url.isLocalFile()) {
if (url.isLocalFile()
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 85, 0)
&& !KNetworkMounts::self()->isOptionEnabledForPath(url.toLocalFile(), KNetworkMounts::StrongSideEffectsOptimizations)
#endif
) {
QString normalizedUrl = QFileInfo(url.toLocalFile()).canonicalFilePath();
if (!normalizedUrl.isEmpty()) {
return QUrl::fromLocalFile(normalizedUrl);
......
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