diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2022-10-27 14:23:51 +0300 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2022-10-31 16:47:03 +0300 |
commit | 5b4a085fb67730f387a9f0228dccc2e47d4e87be (patch) | |
tree | 7ce620d053d4d9bc22ae964ac2962d38eef072df /src/libs/installer | |
parent | 37089baf9aafc2a94ed5bbe88f8ecb90f74af9ab (diff) |
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 <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/installer')
-rw-r--r-- | src/libs/installer/libarchivearchive.cpp | 4 |
1 files 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 |