Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/gui/updater/ocupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "theme.h"

Check failure on line 7 in src/gui/updater/ocupdater.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/updater/ocupdater.cpp:7:10 [clang-diagnostic-error]

'theme.h' file not found
#include "configfile.h"
#include "common/utility.h"
#include "accessmanager.h"
Expand All @@ -26,6 +26,7 @@
const auto updateTargetVersionC = QStringLiteral("Updater/updateTargetVersion");
const auto updateTargetVersionStringC = QStringLiteral("Updater/updateTargetVersionString");
const auto autoUpdateAttemptedC = QStringLiteral("Updater/autoUpdateAttempted");
const auto msiLogFileNameC = QStringLiteral("msi.log");
}

UpdaterScheduler::UpdaterScheduler(QObject *parent)
Expand Down Expand Up @@ -219,7 +220,7 @@
return QDir::toNativeSeparators(path);
};

QString msiLogFile = cfg.configPath() + "msi.log";
QString msiLogFile = cfg.configPath() + msiLogFileNameC;
QString command = QStringLiteral("&{msiexec /i '%1' /L*V '%2'| Out-Null ; &'%3'}")
.arg(preparePathForPowershell(updateFile))
.arg(preparePathForPowershell(msiLogFile))
Expand Down Expand Up @@ -304,8 +305,23 @@
ConfigFile cfg;
QSettings settings(cfg.configFile(), QSettings::IniFormat);
QString updateFileName = settings.value(updateAvailableC).toString();
if (!updateFileName.isEmpty())
QFile::remove(updateFileName);
if (!updateFileName.isEmpty()) {
if (QFile::remove(updateFileName)) {
qCInfo(lcUpdater) << "Removed updater file:" << updateFileName;
} else {
qCWarning(lcUpdater) << "Failed to remove updater file:" << updateFileName;
}
}
// Also try to remove the msi log file (created when running msiexec)
const auto msiLogFileName = QString{cfg.configPath() + msiLogFileNameC};
if (QFile::exists(msiLogFileName)) {
if (QFile::remove(msiLogFileName)) {
qCInfo(lcUpdater) << "Removed msi log file:" << msiLogFileName;
} else {
qCWarning(lcUpdater) << "Failed to remove msi log file:" << msiLogFileName;
}
}

settings.remove(updateAvailableC);
settings.remove(updateTargetVersionC);
settings.remove(updateTargetVersionStringC);
Expand Down Expand Up @@ -522,6 +538,13 @@
return false;
}
} else {
// No internal updater was executed (possible manual install).
// If the app has already been upgraded externally, clean up leftover msi and log files.
if (updateSucceeded()) {
qCInfo(lcUpdater) << "Detected externally installed update - cleaning leftover msi and log files.";
wipeUpdateData();
return false;
}
qCInfo(lcUpdater) << "Triggering an update";
return performUpdate();
}
Expand Down
Loading