Skip to content

Commit 416f85e

Browse files
committed
helium/winsparkle: don't redownload staged updates
hopefully fixes #317
1 parent c51dc6f commit 416f85e

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

patches/helium/windows/updater/winsparkle-headless-ui.patch

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
Notifies the UI that a new version is available.
102102
--- /dev/null
103103
+++ b/third_party/winsparkle/src/ui_headless.cpp
104-
@@ -0,0 +1,130 @@
104+
@@ -0,0 +1,148 @@
105105
+// Copyright 2026 The Helium Authors
106106
+// You can use, redistribute, and/or modify this source code under
107107
+// the terms of the GPL-3.0 license that can be found in the LICENSE file.
@@ -118,6 +118,7 @@
118118
+#include "settings.h"
119119
+#include "threads.h"
120120
+#include "ui.h"
121+
+#include "updatechecker.h"
121122
+#include "updatedownloader.h"
122123
+#include "utils.h"
123124
+#include "winsparkle.h"
@@ -130,6 +131,18 @@
130131
+
131132
+CriticalSection g_downloaderCS;
132133
+std::unique_ptr<UpdateDownloader> g_downloader;
134+
+std::string g_downloadedVersion;
135+
+
136+
+bool UpdateAlreadyDownloaded(const std::string& version) {
137+
+ CriticalSectionLocker lock(g_downloaderCS);
138+
+ return !g_downloadedVersion.empty() &&
139+
+ UpdateChecker::CompareVersions(version, g_downloadedVersion) <= 0;
140+
+}
141+
+
142+
+void RememberDownloadedUpdate(const std::string& version) {
143+
+ CriticalSectionLocker lock(g_downloaderCS);
144+
+ g_downloadedVersion = version;
145+
+}
133146
+
134147
+// Terminate and destroy any outstanding downloader. MUST NOT be called
135148
+// from the downloader's own thread
@@ -184,6 +197,10 @@
184197
+
185198
+// static
186199
+void UI::NotifyUpdateAvailable(const Appcast& info, bool) {
200+
+ if (UpdateAlreadyDownloaded(info.Version)) {
201+
+ return;
202+
+ }
203+
+
187204
+ ApplicationController::NotifyUpdateFound();
188205
+
189206
+ if (!info.HasDownload()) {
@@ -211,6 +228,7 @@
211228
+
212229
+ switch (ApplicationController::UserRunInstallerCallback(updateFile.c_str())) {
213230
+ case 1:
231+
+ RememberDownloadedUpdate(appcast.Version);
214232
+ break;
215233
+ case WINSPARKLE_RETURN_ERROR:
216234
+ NotifyUpdateError("the installer callback reported a failure");

0 commit comments

Comments
 (0)