|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.ComponentModel.DataAnnotations; |
| 4 | +using System.IO; |
4 | 5 | using System.Runtime.InteropServices; |
5 | 6 | using System.Threading; |
6 | 7 | using System.Threading.Tasks; |
|
11 | 12 | using Microsoft.UI.Xaml; |
12 | 13 | using NetSparkleUpdater; |
13 | 14 | using NetSparkleUpdater.AppCastHandlers; |
| 15 | +using NetSparkleUpdater.AssemblyAccessors; |
| 16 | +using NetSparkleUpdater.Configurations; |
14 | 17 | using NetSparkleUpdater.Enums; |
15 | 18 | using NetSparkleUpdater.Interfaces; |
16 | 19 | using NetSparkleUpdater.SignatureVerifiers; |
@@ -94,10 +97,16 @@ public SparkleUpdateController(ILogger<SparkleUpdateController> logger, IOptions |
94 | 97 | publicKey: _config.PublicKeyBase64, |
95 | 98 | readFileBeingVerifiedInChunks: true); |
96 | 99 |
|
| 100 | + // Tell NetSparkle to store its configuration in the same directory as |
| 101 | + // our other config files. |
| 102 | + var appConfigDir = SettingsManagerUtils.AppSettingsDirectory(); |
| 103 | + var sparkleConfigPath = Path.Combine(appConfigDir, "updater.json"); |
| 104 | + var sparkleAssemblyAccessor = new AssemblyDiagnosticsAccessor(null); // null => use current executable path |
| 105 | + var sparkleConfig = new JSONConfiguration(sparkleAssemblyAccessor, sparkleConfigPath); |
| 106 | + |
97 | 107 | _sparkle = new SparkleUpdater(_config.AppCastUrl, checker) |
98 | 108 | { |
99 | | - // TODO: custom Configuration for persistence, could just specify |
100 | | - // our own save path with JSONConfiguration TBH |
| 109 | + Configuration = sparkleConfig, |
101 | 110 | // GitHub releases endpoint returns a random UUID as the filename, |
102 | 111 | // so we tell NetSparkle to ignore it and use the last segment of |
103 | 112 | // the URL instead. |
@@ -141,14 +150,14 @@ public async Task CheckForUpdatesNow() |
141 | 150 | try |
142 | 151 | { |
143 | 152 | if (coderFactory is not null) |
144 | | - coderFactory.ForceDisableToasts = true; |
| 153 | + coderFactory.ForceDisableToastMessages = true; |
145 | 154 |
|
146 | 155 | await _sparkle.CheckForUpdatesAtUserRequest(true); |
147 | 156 | } |
148 | 157 | finally |
149 | 158 | { |
150 | 159 | if (coderFactory is not null) |
151 | | - coderFactory.ForceDisableToasts = false; |
| 160 | + coderFactory.ForceDisableToastMessages = false; |
152 | 161 | } |
153 | 162 | } |
154 | 163 |
|
@@ -192,7 +201,7 @@ public override List<AppCastItem> FilterUpdates(List<AppCastItem> items) |
192 | 201 | // ReSharper disable once InconsistentNaming // the interface name is "UI", not "Ui" |
193 | 202 | public class CoderSparkleUIFactory(IUserNotifier userNotifier, IUpdaterUpdateAvailableViewModelFactory updateAvailableViewModelFactory) : IUIFactory |
194 | 203 | { |
195 | | - public bool ForceDisableToasts; |
| 204 | + public bool ForceDisableToastMessages; |
196 | 205 |
|
197 | 206 | bool IUIFactory.HideReleaseNotes { get; set; } |
198 | 207 | bool IUIFactory.HideSkipButton { get; set; } |
@@ -276,7 +285,7 @@ void IUIFactory.ShowDownloadErrorMessage(string message, string? appcastUrl) |
276 | 285 |
|
277 | 286 | bool IUIFactory.CanShowToastMessages() |
278 | 287 | { |
279 | | - return !ForceDisableToasts; |
| 288 | + return !ForceDisableToastMessages; |
280 | 289 | } |
281 | 290 |
|
282 | 291 | void IUIFactory.ShowToast(Action clickHandler) |
|
0 commit comments