@@ -30,6 +30,7 @@ public partial class App : System.Windows.Application
3030 private const string DashboardUrl = "http://127.0.0.1:31337/" ;
3131
3232 private WebApplication ? _server ;
33+ private string [ ] _arguments = [ ] ;
3334 private TrayPresence ? _tray ;
3435 private MainWindow ? _overlay ;
3536 private Settings _settings = new ( ) ;
@@ -45,6 +46,10 @@ protected override async void OnStartup(StartupEventArgs e)
4546
4647 // Before Settings.Load, so --data moves the whole app - overlay
4748 // preferences and WebView2 profile included - and not just the server.
49+ // Kept for Restart: an update replaces the file and starts it again,
50+ // and it has to come back as the same copy rather than the default one.
51+ _arguments = e . Args ;
52+
4853 Core . AppPaths . UseFromArguments ( e . Args ) ;
4954
5055 _settings = Settings . Load ( ) ;
@@ -170,11 +175,29 @@ private void PickInstallFolder()
170175 Restart ( ) ;
171176 }
172177
178+ /// <summary>
179+ /// Starts this application again and stands down.
180+ /// </summary>
181+ /// <remarks>
182+ /// The arguments come too. Dropping them looks harmless because most people
183+ /// pass none, but --data moves every store and --path names the install, so
184+ /// a restart without them silently points a second copy at the default
185+ /// folder - somebody else's real data, if this one was deliberately kept
186+ /// away from it. Found by updating a copy running on --data and watching the
187+ /// new process come back with none.
188+ /// </remarks>
173189 private void Restart ( )
174190 {
175191 var exe = Environment . ProcessPath ;
192+
176193 if ( exe is not null )
177- Process . Start ( new ProcessStartInfo ( exe ) { UseShellExecute = true } ) ;
194+ {
195+ var start = new ProcessStartInfo ( exe ) { UseShellExecute = true } ;
196+ foreach ( var argument in _arguments )
197+ start . ArgumentList . Add ( argument ) ;
198+
199+ Process . Start ( start ) ;
200+ }
178201
179202 Quit ( ) ;
180203 }
0 commit comments