Skip to content
Draft
Changes from 1 commit
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
24 changes: 22 additions & 2 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 Down Expand Up @@ -304,8 +304,21 @@
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)
QString msiLogFileName = cfg.configPath() + "msi.log";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider using a constant for msi.log.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I’ve added a separate commit introducing a constant msiLogFileNameC as suggested.

if (QFile::remove(msiLogFileName)) {
qCInfo(lcUpdater) << "Removed msi log file:" << msiLogFileName;
} else {
qCWarning(lcUpdater) << "Failed to remove msi log file:" << msiLogFileName;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be good to check whether the current platform is Windows? I wouldn't expect an msi log on any other system.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Aiiaiiio, thanks for the suggestion! From what I see, the changes are in NSISUpdater::wipeUpdateData() which is a Windows-specific subclass of OCUpdater. So this code isn’t compiled on other platforms than Windows and no additional platform check should be needed.

}

settings.remove(updateAvailableC);
settings.remove(updateTargetVersionC);
settings.remove(updateTargetVersionStringC);
Expand Down Expand Up @@ -522,6 +535,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