Commit e1fca1f8 authored by Elvis Angelaccio's avatar Elvis Angelaccio
Browse files

Fix subfolder detection of RPM archives

Filenames in a RPM archive start with the ./ prefix.
This means that "." is detected as the subfolder name by the ListJob.

We now remove this prefix to prevent this meaningless string to show up in the extraction dialog,
as the value of the subfolder QLineEdit. An autotest is added as well to assert
this behavior.

See also

parent a89e1799
......@@ -29,6 +29,7 @@
#include "ark_debug.h"
#include <QFileInfo>
#include <QRegularExpression>
#include <QThread>
#include <KLocalizedString>
......@@ -238,8 +239,9 @@ void ListJob::onNewEntry(const ArchiveEntry& entry)
if (m_isSingleFolderArchive) {
const QString fileName(entry[FileName].toString());
const QString basePath(fileName.split(QLatin1Char( '/' )).at(0));
// RPM filenames have the ./ prefix, and "." would be detected as the subfolder name, so we remove it.
const QString fileName = entry[FileName].toString().replace(QRegularExpression(QStringLiteral("^\\./")), QString());
const QString basePath = fileName.split(QLatin1Char('/')).at(0);
if (m_basePath.isEmpty()) {
m_basePath = basePath;
......@@ -78,6 +78,13 @@ void ArchiveTest::testProperties_data()
<< QFileInfo(archivePath).fileName()
<< false << false << false
<< QStringLiteral("archivetest_unencrypted");
archivePath = QFINDTESTDATA("data/wget.rpm");
QTest::newRow("rpm archive, no single folder")
<< archivePath
<< QFileInfo(archivePath).fileName()
<< true << false << false
<< QStringLiteral("wget");
void ArchiveTest::testProperties()
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