diff options
author | Adriaan de Groot <adridg@FreeBSD.org> | 2021-05-14 16:15:52 +0000 |
---|---|---|
committer | Adriaan de Groot <adridg@FreeBSD.org> | 2021-05-14 19:08:19 +0000 |
commit | aa6092a1dbfad606ad6430c71eec6add0bbdb4cf (patch) | |
tree | c8304dcd6912da017663fff9d98a9a6e4a8b23e3 | |
parent | aee4556063e8770fd0e4fd28a29f30626d6e235a (diff) | |
download | ports-aa6092a1dbfad606ad6430c71eec6add0bbdb4cf.tar.gz ports-aa6092a1dbfad606ad6430c71eec6add0bbdb4cf.zip |
devel/kf5-kio: backport regression-fixes from upstream
Upstream reports that the following three commits should be
backported for improved performance and accuracy for
mimetype detection in KIO-using applications:
(In https://invent.kde.org/frameworks/kio/commit/)
c748d6987252fafc296cde9351b289ef734cf861
e79da836c34fce66231e396c7215314d0eba51b4
c19876052ecec18a87a82f5950e8909e22e895ba
-rw-r--r-- | devel/kf5-kio/Makefile | 1 | ||||
-rw-r--r-- | devel/kf5-kio/files/patch-autotests_mimetypefinderjobtest.cpp | 39 | ||||
-rw-r--r-- | devel/kf5-kio/files/patch-src_core_mimetypefinderjob.cpp | 22 | ||||
-rw-r--r-- | devel/kf5-kio/files/patch-src_ioslaves_file_file__unix.cpp | 38 |
4 files changed, 100 insertions, 0 deletions
diff --git a/devel/kf5-kio/Makefile b/devel/kf5-kio/Makefile index f7e2435fbc1b..f8d5117ca61e 100644 --- a/devel/kf5-kio/Makefile +++ b/devel/kf5-kio/Makefile @@ -1,5 +1,6 @@ PORTNAME= kio DISTVERSION= ${KDE_FRAMEWORKS_VERSION} +PORTREVISION= 1 CATEGORIES= devel kde kde-frameworks MAINTAINER= kde@FreeBSD.org diff --git a/devel/kf5-kio/files/patch-autotests_mimetypefinderjobtest.cpp b/devel/kf5-kio/files/patch-autotests_mimetypefinderjobtest.cpp new file mode 100644 index 000000000000..c0dd474fc18c --- /dev/null +++ b/devel/kf5-kio/files/patch-autotests_mimetypefinderjobtest.cpp @@ -0,0 +1,39 @@ +--- autotests/mimetypefinderjobtest.cpp.orig 2021-05-06 17:50:59 UTC ++++ autotests/mimetypefinderjobtest.cpp +@@ -48,6 +48,7 @@ void MimeTypeFinderJobTest::determineMimeType_data() + QTest::newRow("text_file_no_extension") << "text/plain" << "srcfile"; + QTest::newRow("desktop_file") << "application/x-desktop" << "foo.desktop"; + QTest::newRow("script") << "application/x-shellscript" << "srcfile.sh"; ++ QTest::newRow("directory") << "inode/directory" << "srcdir"; + /* clang-format on */ + } + +@@ -60,12 +61,27 @@ void MimeTypeFinderJobTest::determineMimeType() + QTemporaryDir tempDir; + const QString srcDir = tempDir.path(); + const QString srcFile = srcDir + QLatin1Char('/') + fileName; +- createSrcFile(srcFile); ++ if (mimeType == "inode/directory") { ++ QVERIFY(QDir(srcDir).mkdir(fileName)); ++ } else { ++ createSrcFile(srcFile); ++ } ++ + QVERIFY(QFile::exists(srcFile)); + const QUrl url = QUrl::fromLocalFile(srcFile); + + // When running a MimeTypeFinderJob + KIO::MimeTypeFinderJob *job = new KIO::MimeTypeFinderJob(url, this); ++ QVERIFY2(job->exec(), qPrintable(job->errorString())); ++ QCOMPARE(job->mimeType(), mimeType); ++ ++ // Check that the result is the same when accessing the source ++ // file through a symbolic link (bug #436708) ++ const QString srcLink = srcDir + QLatin1String("/link_") + fileName; ++ QVERIFY(QFile::link(srcFile, srcLink)); ++ const QUrl linkUrl = QUrl::fromLocalFile(srcLink); ++ ++ job = new KIO::MimeTypeFinderJob(linkUrl, this); + QVERIFY2(job->exec(), qPrintable(job->errorString())); + QCOMPARE(job->mimeType(), mimeType); + } diff --git a/devel/kf5-kio/files/patch-src_core_mimetypefinderjob.cpp b/devel/kf5-kio/files/patch-src_core_mimetypefinderjob.cpp new file mode 100644 index 000000000000..42c0b4929b01 --- /dev/null +++ b/devel/kf5-kio/files/patch-src_core_mimetypefinderjob.cpp @@ -0,0 +1,22 @@ +--- src/core/mimetypefinderjob.cpp.orig 2021-05-14 15:38:26 UTC ++++ 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::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")); + } +@@ -146,6 +148,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()) { diff --git a/devel/kf5-kio/files/patch-src_ioslaves_file_file__unix.cpp b/devel/kf5-kio/files/patch-src_ioslaves_file_file__unix.cpp new file mode 100644 index 000000000000..2898beb65703 --- /dev/null +++ b/devel/kf5-kio/files/patch-src_ioslaves_file_file__unix.cpp @@ -0,0 +1,38 @@ +--- src/ioslaves/file/file_unix.cpp.orig 2021-05-06 17:50:59 UTC ++++ src/ioslaves/file/file_unix.cpp +@@ -364,7 +364,7 @@ inline static time_t stat_mtime(QT_STATBUF &buf) + } + #endif + +-static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details) ++static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details, const QUrl &url) + { + assert(entry.count() == 0); // by contract :-) + int entries = 0; +@@ -539,7 +539,7 @@ static bool createUDSEntry(const QString &filename, co + + if (details & KIO::StatMimeType) { + QMimeDatabase db; +- entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(filename).name()); ++ entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(url.toLocalFile()).name()); + } + + return true; +@@ -1186,7 +1186,7 @@ void FileProtocol::listDir(const QUrl &url) + listEntry(entry); + + } else { +- if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details)) { ++ if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details, url)) { + #if HAVE_SYS_XATTR_H + if (isNtfsHidden(filename)) { + bool ntfsHidden = true; +@@ -1476,7 +1476,7 @@ void FileProtocol::stat(const QUrl &url) + const KIO::StatDetails details = getStatDetails(); + + UDSEntry entry; +- if (!createUDSEntry(url.fileName(), _path, entry, details)) { ++ if (!createUDSEntry(url.fileName(), _path, entry, details, url)) { + error(KIO::ERR_DOES_NOT_EXIST, path); + return; + } |