1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . ComponentModel . DataAnnotations ;
4
+ using System . Runtime . InteropServices ;
4
5
using System . Threading ;
5
6
using System . Threading . Tasks ;
6
7
using Coder . Desktop . App . ViewModels ;
@@ -43,7 +44,7 @@ public class UpdaterConfig
43
44
public bool EnableUpdater { get ; set ; } = true ;
44
45
//[Required] public string UpdateAppCastUrl { get; set; } = "https://releases.coder.com/coder-desktop/windows/appcast.xml";
45
46
[ Required ] public string UpdateAppCastUrl { get ; set ; } = "http://localhost:8000/appcast.xml" ;
46
- [ Required ] public string UpdatePublicKeyBase64 { get ; set ; } = "Uxc0ir6j3GMhkL5D1O/W3lsD4BNk5puwM9hohNfm32k =" ;
47
+ [ Required ] public string UpdatePublicKeyBase64 { get ; set ; } = "NNWN4c+3PmMuAf2G1ERLlu0EwhzHfSiUugOt120hrH8 =" ;
47
48
public UpdateChannel ? ForcedUpdateChannel { get ; set ; } = null ;
48
49
}
49
50
@@ -83,8 +84,7 @@ public SparkleUpdateController(ILogger<SparkleUpdateController> logger, IOptions
83
84
// Swift's Sparkle does not support verifying app cast signatures yet,
84
85
// but we use this functionality on Windows for added security against
85
86
// malicious release notes.
86
- // TODO: REENABLE STRICT CHECKING
87
- var checker = new Ed25519Checker ( SecurityMode . Unsafe ,
87
+ var checker = new Ed25519Checker ( SecurityMode . Strict ,
88
88
publicKey : _config . UpdatePublicKeyBase64 ,
89
89
readFileBeingVerifiedInChunks : true ) ;
90
90
@@ -93,7 +93,7 @@ public SparkleUpdateController(ILogger<SparkleUpdateController> logger, IOptions
93
93
// TODO: custom Configuration for persistence, could just specify
94
94
// our own save path with JSONConfiguration TBH
95
95
LogWriter = new CoderSparkleLogger ( logger ) ,
96
- AppCastHelper = new CoderSparkleAppCastHelper ( logger , _config . ForcedUpdateChannel ) ,
96
+ AppCastHelper = new CoderSparkleAppCastHelper ( _config . ForcedUpdateChannel ) ,
97
97
UIFactory = uiFactory ,
98
98
UseNotificationToast = uiFactory . CanShowToastMessages ( ) ,
99
99
RelaunchAfterUpdate = true ,
@@ -103,7 +103,7 @@ public SparkleUpdateController(ILogger<SparkleUpdateController> logger, IOptions
103
103
104
104
// TODO: user preference for automatic checking. Remember to
105
105
// StopLoop/StartLoop if it changes.
106
- #if ! DEBUG || true
106
+ #if ! DEBUG
107
107
_ = _sparkle . StartLoop ( true , UpdateCheckInterval ) ;
108
108
#endif
109
109
}
@@ -157,22 +157,20 @@ public void PrintMessage(string message, params object[]? arguments)
157
157
}
158
158
}
159
159
160
- public class CoderSparkleAppCastHelper : AppCastHelper
160
+ public class CoderSparkleAppCastHelper ( UpdateChannel ? forcedChannel ) : AppCastHelper
161
161
{
162
- private readonly UpdateChannel ? _forcedChannel ;
163
-
164
- public CoderSparkleAppCastHelper ( ILogger < SparkleUpdateController > logger , UpdateChannel ? forcedChannel ) : base ( )
165
- {
166
- _forcedChannel = forcedChannel ;
167
- }
162
+ // This might return some other OS if the user compiled the app for some
163
+ // different arch, but the end result is the same: no updates will be found
164
+ // for that arch.
165
+ private static string CurrentOperatingSystem => $ "win-{ RuntimeInformation . ProcessArchitecture . ToString ( ) . ToLowerInvariant ( ) } ";
168
166
169
167
public override List < AppCastItem > FilterUpdates ( List < AppCastItem > items )
170
168
{
171
169
items = base . FilterUpdates ( items ) ;
172
170
173
- // TODO: factor in user choice too once we have a settings page
174
- var channel = _forcedChannel ?? UpdateChannel . Stable ;
175
- return items . FindAll ( i => i . Channel != null && i . Channel == channel . ChannelName ( ) ) ;
171
+ // TODO: factor in user channel choice too once we have a settings page
172
+ var channel = forcedChannel ?? UpdateChannel . Stable ;
173
+ return items . FindAll ( i => i . Channel == channel . ChannelName ( ) && i . OperatingSystem == CurrentOperatingSystem ) ;
176
174
}
177
175
}
178
176
0 commit comments