Fix file deletion when canceling installation

Task-number: QTIFW-1466
Change-Id: I2b9f000cddc63e9eccefb3d86f93ab05a5631581
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
This commit is contained in:
Katja Marttila 2019-11-08 08:03:57 +02:00
parent f667bf73d0
commit 8053f11af1

View File

@ -150,18 +150,18 @@ bool ExtractArchiveOperation::undoOperation()
startUndoProcess(files); startUndoProcess(files);
} else { } else {
const QString filePath = value(QLatin1String("files")).toString(); const QString filePath = value(QLatin1String("files")).toString();
QString target = QCoreApplication::applicationDirPath(); QString targetDir = arguments().at(1);
// Does not change target on non macOS platforms. // Does not change target on non macOS platforms.
if (QInstaller::isInBundle(target, &target)) if (QInstaller::isInBundle(targetDir, &targetDir))
target = QDir::cleanPath(target + QLatin1String("/..")); targetDir = QDir::cleanPath(targetDir + QLatin1String("/.."));
QString fileName = replacePath(filePath, QLatin1String(scRelocatable), target); QString fileName = replacePath(filePath, QLatin1String(scRelocatable), targetDir);
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) { if (file.open(QIODevice::ReadOnly)) {
QDataStream in(&file); QDataStream in(&file);
in >> files; in >> files;
for (int i = 0; i < files.count(); ++i) for (int i = 0; i < files.count(); ++i)
files[i] = replacePath(files.at(i), QLatin1String(scRelocatable), target); files[i] = replacePath(files.at(i), QLatin1String(scRelocatable), targetDir);
startUndoProcess(files); startUndoProcess(files);
QFileInfo fileInfo(file); QFileInfo fileInfo(file);
file.remove(); file.remove();