From d02dcbd47530ce7415668ba35a2f378bf12aef15 Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Tue, 2 Nov 2021 17:12:05 +0200 Subject: Libarchive: Fix extracting hard links pointing to files in archive Since we already adjust the output path for archive entries, libarchive would fail with the error string "Hard-link target '...' does not exist" for hard links referring to extracted files. Fix by also adjusting the hard link target paths. Task-number: QTIFW-2403 Change-Id: I8f78117c5b0707a70c76433ca1c1483ea49b432b Reviewed-by: Katja Marttila --- src/libs/installer/libarchivearchive.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libs/installer/libarchivearchive.cpp b/src/libs/installer/libarchivearchive.cpp index 46200560b..d3a79bd40 100644 --- a/src/libs/installer/libarchivearchive.cpp +++ b/src/libs/installer/libarchivearchive.cpp @@ -123,6 +123,12 @@ void ExtractWorker::extract(const QString &dirPath, const quint64 totalFiles) const QString outputPath = dirPath + QDir::separator() + QString::fromLocal8Bit(current); archive_entry_set_pathname(entry, outputPath.toLocal8Bit()); + const char *hardlink = archive_entry_hardlink(entry); + if (hardlink) { + const QString hardLinkPath = dirPath + QDir::separator() + QString::fromLocal8Bit(hardlink); + archive_entry_set_hardlink(entry, hardLinkPath.toLocal8Bit()); + } + emit currentEntryChanged(outputPath); if (!writeEntry(reader.get(), writer.get(), entry)) return; @@ -440,6 +446,12 @@ bool LibArchiveArchive::extract(const QString &dirPath, const quint64 totalFiles const QString outputPath = dirPath + QDir::separator() + QString::fromLocal8Bit(current); archive_entry_set_pathname(entry, outputPath.toLocal8Bit()); + const char *hardlink = archive_entry_hardlink(entry); + if (hardlink) { + const QString hardLinkPath = dirPath + QDir::separator() + QString::fromLocal8Bit(hardlink); + archive_entry_set_hardlink(entry, hardLinkPath.toLocal8Bit()); + } + emit currentEntryChanged(outputPath); if (!writeEntry(reader.get(), writer.get(), entry)) throw Error(errorString()); // appropriate error string set in writeEntry() -- cgit v1.2.3