Skip to content
Open
Show file tree
Hide file tree
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
23 changes: 19 additions & 4 deletions src/server/updater/windowsupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ void WindowsUpdater::startInstaller() {
setState(UpdateState::DownloadError);
return;
}
if (!std::filesystem::exists(filepath)) {
LOG_WARN(Log::instance()->getLogger(), "Installer file not found.");
if (_autoUpdate) {
LOG_ERROR(Log::instance()->getLogger(), "Already tried to re-download the installer before.");
setState(UpdateState::UpdateError);
return;
}
_autoUpdate = true;
downloadUpdate();
return;
}
_autoUpdate = false;

LOGW_INFO(Log::instance()->getLogger(), L"Starting updater " << Utility::formatSyncPath(filepath));
const auto cmd = filepath.wstring() + L" /S /launch";
(void) Utility::runDetachedProcess(cmd);
Expand Down Expand Up @@ -119,10 +132,8 @@ void WindowsUpdater::downloadFinished(const UniqueId jobId) {
return;
}
if (!std::filesystem::exists(filepath)) {
const auto error = "Installer file not found.";
sentry::Handler::captureMessage(sentry::Level::Warning, "WindowsUpdater::downloadFinished", error);
LOG_ERROR(Log::instance()->getLogger(), error);
setState(UpdateState::DownloadError);
LOG_ERROR(Log::instance()->getLogger(), "Installer file not found.");
downloadUpdate();
return;
}

Expand All @@ -134,6 +145,10 @@ void WindowsUpdater::downloadFinished(const UniqueId jobId) {
LOGW_INFO(Log::instance()->getLogger(),
L"Installer downloaded at: " << Utility::formatSyncPath(filepath) << L". Update is ready to be installed.");
setState(UpdateState::Ready);
if (_autoUpdate) {
// Start the installer automatically.
startInstaller();
}
}

bool WindowsUpdater::getInstallerPath(SyncPath &path) const {
Expand Down
2 changes: 2 additions & 0 deletions src/server/updater/windowsupdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class WindowsUpdater : public AbstractUpdater {
* @return true if the signature is valid.
*/
virtual bool verifyDigitalSignature(const SyncPath &filepath);

bool _autoUpdate{false};
};

} // namespace KDC