kio/0002-MimeTypeFinderJob-the-StatJob-details-should-include.patch
Wolfgang Bauer ec2550ad7f Accepting request 893118 from home:Vogtinator:branches:KDE:Frameworks5
- Add patches to fix issues with MimeTypeFinderJob (kde#398908):
  * 0001-MimeTypeFinderJob-Resolve-symlinks-for-a-local-file.patch
  * 0002-MimeTypeFinderJob-the-StatJob-details-should-include.patch
  * 0003-kio_file-pass-the-absolute-path-to-QMimeDatabase-mim.patch

OBS-URL: https://build.opensuse.org/request/show/893118
OBS-URL: https://build.opensuse.org/package/show/KDE:Frameworks5/kio?expand=0&rev=335
2021-05-15 08:23:41 +00:00

54 lines
2.2 KiB
Diff

From e78b0cd47422869e980db633cbdc0c7cfcdd8dd8 Mon Sep 17 00:00:00 2001
From: Ahmad Samir <a.samirh78@gmail.com>
Date: Thu, 13 May 2021 17:02:52 +0200
Subject: [PATCH 2/3] MimeTypeFinderJob: the StatJob details should include the
mimetype
Apparently we forgot to specify that we want the UDS_MIME_TYPE field in
the statFile() method (both when it lived in OpenUrlJob and when it was moved
to MimeTypeFinderJob). And now there is a dedicated StatJob flag, StatMimeType,
that we can use.
Not passing KIO::StatMimeType when creating the StatJob meant the code always
used a get job to determine the mime type, which mean that e.g. opening an
ISO file from Dolphin, which supposedly just needs to launch Ark, had the
whole file read into memory, which means that opening a couple of ISO's and
you're out of memory...
Thanks to sitter for doing a big chunk of the investigative work in the bug
report.
CCBUG: 398908
(cherry picked from commit c19876052ecec18a87a82f5950e8909e22e895ba)
---
src/core/mimetypefinderjob.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/core/mimetypefinderjob.cpp b/src/core/mimetypefinderjob.cpp
index 48fc8c28..baca5869 100644
--- a/src/core/mimetypefinderjob.cpp
+++ b/src/core/mimetypefinderjob.cpp
@@ -122,7 +122,9 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
{
Q_ASSERT(m_mimeTypeName.isEmpty());
- KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, KIO::StatBasic | KIO::StatResolveSymlink, KIO::HideProgressInfo);
+ static constexpr auto statFlags = KIO::StatBasic | KIO::StatResolveSymlink | KIO::StatMimeType;
+
+ KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, statFlags, KIO::HideProgressInfo);
if (!m_authPrompts) {
job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
}
@@ -147,6 +149,8 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
const KIO::UDSEntry entry = job->statResult();
+ qCDebug(KIO_CORE) << "UDSEntry from StatJob in MimeTypeFinderJob" << entry;
+
const QString localPath = entry.stringValue(KIO::UDSEntry::UDS_LOCAL_PATH);
if (!localPath.isEmpty()) {
m_url = QUrl::fromLocalFile(localPath);
--
2.25.1