Commit 94d8567d authored by Elvis Angelaccio's avatar Elvis Angelaccio

Fix drag-and-drop with RPM archives

RPM paths start with ./ so removing the rootNode substring starting
from index 0 is wrong.

BUG: 369535
FIXED-IN: 16.08.2

Differential Revision: D2895
parent b345cabe
......@@ -557,6 +557,17 @@ void ArchiveTest::testExtraction_data()
<< QVariantList()
<< optionsPreservePaths
<< 3;
archivePath = QFINDTESTDATA("data/firmware-pine64-20160329-6.1.aarch64.rpm");
QTest::newRow("#369535: broken drag-and-drop from rpm")
<< archivePath
<< QVariantList {
// Remember that RPM paths start with ./
QVariant::fromValue(fileRootNodePair(QStringLiteral("./boot/sunxi-spl.bin"), QStringLiteral("boot/"))),
QVariant::fromValue(fileRootNodePair(QStringLiteral("./boot/u-boot.img"), QStringLiteral("boot/")))
}
<< dragAndDropOptions
<< 2;
}
void ArchiveTest::testExtraction()
......
......@@ -286,14 +286,13 @@ bool LibarchivePlugin::copyFiles(const QVariantList& files, const QString& desti
entryFI = QFileInfo(fileWithoutPath);
// OR, if the file has a rootNode attached, remove it from file path.
} else if (!extractAll && removeRootNode && entryName != fileBeingRenamed &&
!files.at(index).value<fileRootNodePair>().rootNode.isEmpty()) {
//qCDebug(ARK) << "Removing" << files.at(index).value<fileRootNodePair>().rootNode << "from" << entryName;
const QString truncatedFilename(entryName.remove(0, files.at(index).value<fileRootNodePair>().rootNode.size()));
archive_entry_copy_pathname(entry, QFile::encodeName(truncatedFilename).constData());
entryFI = QFileInfo(truncatedFilename);
} else if (!extractAll && removeRootNode && entryName != fileBeingRenamed) {
const QString rootNode = files.at(index).value<fileRootNodePair>().rootNode;
if (!rootNode.isEmpty()) {
const QString truncatedFilename = entryName.remove(entryName.indexOf(rootNode), rootNode.size());
archive_entry_copy_pathname(entry, QFile::encodeName(truncatedFilename).constData());
entryFI = QFileInfo(truncatedFilename);
}
}
// Check if the file about to be written already exists.
......
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