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
This commit is contained in:
parent
aee4556063
commit
aa6092a1db
4 changed files with 100 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
PORTNAME= kio
|
||||
DISTVERSION= ${KDE_FRAMEWORKS_VERSION}
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= devel kde kde-frameworks
|
||||
|
||||
MAINTAINER= kde@FreeBSD.org
|
||||
|
|
|
@ -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);
|
||||
}
|
22
devel/kf5-kio/files/patch-src_core_mimetypefinderjob.cpp
Normal file
22
devel/kf5-kio/files/patch-src_core_mimetypefinderjob.cpp
Normal file
|
@ -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()) {
|
38
devel/kf5-kio/files/patch-src_ioslaves_file_file__unix.cpp
Normal file
38
devel/kf5-kio/files/patch-src_ioslaves_file_file__unix.cpp
Normal file
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue