From 2d618ef8fa7df7f01b680fdcec0799692a8f6001 Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Thu, 27 Oct 2022 14:23:51 +0300 Subject: ExtractOp: fix leftover empty directories when 'targetDir' arg is used The problem was that the directory passed for the DirectoryGuard object handling the creation of leading directories was missing the target directory itself, instead the path ended to its parent directory. When installer does the undo-step for Extract operation, only empty directories are deleted, so in case any directory from a path is missing from the created directory list, the leading directories won't be also deleted. QFileInfo::absolutePath() returns the path of the parent directory for the given path even if it is a directory, fix by using instead the QFileInfo::absoluteFilePath(), which includes the name after the last directory separator. Task-number: QTIFW-2764 Change-Id: I5b03142b46db566615f4983fa3e2ff2690f25262 Reviewed-by: Katja Marttila (cherry picked from commit 5b4a085fb67730f387a9f0228dccc2e47d4e87be) --- src/libs/installer/libarchivearchive.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/installer/libarchivearchive.cpp b/src/libs/installer/libarchivearchive.cpp index 0ef317c67..4102518f4 100644 --- a/src/libs/installer/libarchivearchive.cpp +++ b/src/libs/installer/libarchivearchive.cpp @@ -276,7 +276,7 @@ void ExtractWorker::extract(const QString &dirPath, const quint64 totalFiles) LibArchiveArchive::configureReader(reader.get()); LibArchiveArchive::configureDiskWriter(writer.get()); - DirectoryGuard targetDir(QFileInfo(dirPath).absolutePath()); + DirectoryGuard targetDir(QFileInfo(dirPath).absoluteFilePath()); try { const QStringList createdDirs = targetDir.tryCreate(); // Make sure that all leading directories created get removed as well @@ -622,7 +622,7 @@ bool LibArchiveArchive::extract(const QString &dirPath, const quint64 totalFiles configureReader(reader.get()); configureDiskWriter(writer.get()); - DirectoryGuard targetDir(QFileInfo(dirPath).absolutePath()); + DirectoryGuard targetDir(QFileInfo(dirPath).absoluteFilePath()); try { const QStringList createdDirs = targetDir.tryCreate(); // Make sure that all leading directories created get removed as well -- cgit v1.2.3