From bfa8788988bbbb65aac24f43b2c1bb090b210459 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 8 Dec 2022 09:24:52 +0200 Subject: [PATCH] kfile: remove archive KIO slaves leftovers Signed-off-by: Ivailo Monev --- kdecore/sycoca/kprotocolinfo.h | 4 +-- kfile/kurlnavigator.cpp | 44 ------------------------------- kfile/tests/kurlnavigatortest.cpp | 30 --------------------- kfile/tests/kurlnavigatortest.h | 2 -- 4 files changed, 2 insertions(+), 78 deletions(-) diff --git a/kdecore/sycoca/kprotocolinfo.h b/kdecore/sycoca/kprotocolinfo.h index 75f13be0..0f1065a0 100644 --- a/kdecore/sycoca/kprotocolinfo.h +++ b/kdecore/sycoca/kprotocolinfo.h @@ -127,7 +127,7 @@ public: * Returns whether the protocol can act as a filter protocol. * * A filter protocol can operate on data that is passed to it - * but does not retrieve/store data itself, like gzip. + * but does not retrieve/store data itself, like sftp. * A filter protocol is the opposite of a source protocol. * * The "source=" field in the protocol description file determines @@ -136,7 +136,7 @@ public: * "false" for filter protocol. * * @param url the url to check - * @return true if the protocol is a filter (e.g. gzip), false if the + * @return true if the protocol is a filter (e.g. sftp), false if the * protocol is a helper or source */ static bool isFilterProtocol( const KUrl &url ); diff --git a/kfile/kurlnavigator.cpp b/kfile/kurlnavigator.cpp index 61998dbd..55ddad1e 100644 --- a/kfile/kurlnavigator.cpp +++ b/kfile/kurlnavigator.cpp @@ -146,12 +146,6 @@ public: */ QString retrievePlacePath() const; - /** - * Returns true, if the MIME type of the path represents a - * compressed file like TAR or ZIP. - */ - bool isCompressedPath(const KUrl& path) const; - void removeTrailingSlash(QString& url) const; /** @@ -762,20 +756,6 @@ QString KUrlNavigator::Private::retrievePlacePath() const return placePath; } -bool KUrlNavigator::Private::isCompressedPath(const KUrl& url) const -{ - const KMimeType::Ptr mime = KMimeType::findByPath(url.path(KUrl::RemoveTrailingSlash)); - // Note: this list of MIME types depends on the protocols implemented by kio_archive - return mime->is("application/x-compressed-tar") || - mime->is("application/x-bzip-compressed-tar") || - mime->is("application/x-lzma-compressed-tar") || - mime->is("application/x-xz-compressed-tar") || - mime->is("application/x-tar") || - mime->is("application/x-tarz") || - mime->is("application/zip") || - mime->is("application/x-archive"); -} - void KUrlNavigator::Private::removeTrailingSlash(QString& url) const { const int length = url.length(); @@ -991,30 +971,6 @@ void KUrlNavigator::setLocationUrl(const KUrl& newUrl) KUrl url = newUrl; url.cleanPath(); - if ((url.protocol() == QLatin1String("tar")) || (url.protocol() == QLatin1String("zip"))) { - // The URL represents a tar- or zip-file. Check whether - // the URL is really part of the tar- or zip-file, otherwise - // replace it by the local path again. - bool insideCompressedPath = d->isCompressedPath(url); - if (!insideCompressedPath) { - KUrl prevUrl = url; - KUrl parentUrl = url.upUrl(); - while (parentUrl != prevUrl) { - if (d->isCompressedPath(parentUrl)) { - insideCompressedPath = true; - break; - } - prevUrl = parentUrl; - parentUrl = parentUrl.upUrl(); - } - } - if (!insideCompressedPath) { - // drop the tar: or zip: protocol since we are not - // inside the compressed path - url.setProtocol("file"); - } - } - // Check whether current history element has the same URL. // If this is the case, just ignore setting the URL. const LocationData& data = d->m_history[d->m_historyIndex]; diff --git a/kfile/tests/kurlnavigatortest.cpp b/kfile/tests/kurlnavigatortest.cpp index 71340b1f..a4b26db4 100644 --- a/kfile/tests/kurlnavigatortest.cpp +++ b/kfile/tests/kurlnavigatortest.cpp @@ -159,34 +159,4 @@ void KUrlNavigatorTest::testHistoryInsert() QCOMPARE(m_navigator->historySize(), 4); } -/** - * When the current URL is inside an archive and the user goes "up", it is expected - * that the new URL is that of the folder containing the archive (unless the URL was - * in a subfolder inside the archive). Furthermore, the protocol should be "file". - * An empty protocol would lead to problems in Dolphin, see - * - * https://bugs.kde.org/show_bug.cgi?id=251553 - */ - -void KUrlNavigatorTest::bug251553_goUpFromArchive() -{ - m_navigator->setLocationUrl(KUrl("zip:/test/archive.zip")); - QCOMPARE(m_navigator->locationUrl().path(), QLatin1String("/test/archive.zip")); - QCOMPARE(m_navigator->locationUrl().protocol(), QLatin1String("zip")); - - bool ok = m_navigator->goUp(); - QVERIFY(ok); - QCOMPARE(m_navigator->locationUrl().path(KUrl::AddTrailingSlash), QLatin1String("/test/")); - QCOMPARE(m_navigator->locationUrl().protocol(), QLatin1String("file")); - - m_navigator->setLocationUrl(KUrl("tar:/test/archive.tar.gz")); - QCOMPARE(m_navigator->locationUrl().path(), QLatin1String("/test/archive.tar.gz")); - QCOMPARE(m_navigator->locationUrl().protocol(), QLatin1String("tar")); - - ok = m_navigator->goUp(); - QVERIFY(ok); - QCOMPARE(m_navigator->locationUrl().path(KUrl::AddTrailingSlash), QLatin1String("/test/")); - QCOMPARE(m_navigator->locationUrl().protocol(), QLatin1String("file")); -} - #include "moc_kurlnavigatortest.cpp" diff --git a/kfile/tests/kurlnavigatortest.h b/kfile/tests/kurlnavigatortest.h index 4b19b616..d36658e5 100644 --- a/kfile/tests/kurlnavigatortest.h +++ b/kfile/tests/kurlnavigatortest.h @@ -36,8 +36,6 @@ private slots: void testGoForward(); void testHistoryInsert(); - void bug251553_goUpFromArchive(); - private: KUrlNavigator* m_navigator; };