@@ -165,10 +165,12 @@ await updateHelper.DownloadUpdate(
165165 // Handle Linux AppImage update
166166 if ( Compat . IsLinux && Environment . GetEnvironmentVariable ( "APPIMAGE" ) is { } appImage )
167167 {
168- var updateScriptPath = UpdateHelper . UpdateFolder . JoinFile ( "update_script.sh" ) . FullPath ;
169- var newAppImage = UpdateHelper . ExecutablePath . FullPath ;
168+ try
169+ {
170+ var updateScriptPath = UpdateHelper . UpdateFolder . JoinFile ( "update_script.sh" ) . FullPath ;
171+ var newAppImage = UpdateHelper . ExecutablePath . FullPath ;
170172
171- var scriptContent = $ """
173+ var scriptContent = $ """
172174#!/bin/bash
173175PID={ Environment . ProcessId }
174176NEW_APPIMAGE="{ newAppImage . Replace ( "\" " , "\\ \" " ) } "
@@ -183,28 +185,41 @@ sleep 0.5
183185mv -f "$NEW_APPIMAGE" "$OLD_APPIMAGE"
184186chmod +x "$OLD_APPIMAGE"
185187
186- # Launch the new AppImage
187- "$OLD_APPIMAGE" &
188+ # Launch the new AppImage detached
189+ "$OLD_APPIMAGE" > /dev/null 2>&1 &
190+ disown
188191""" ;
189- await File . WriteAllTextAsync ( updateScriptPath , scriptContent ) ;
192+ await File . WriteAllTextAsync ( updateScriptPath , scriptContent ) ;
193+
194+ File . SetUnixFileMode (
195+ updateScriptPath ,
196+ UnixFileMode . UserRead | UnixFileMode . UserWrite | UnixFileMode . UserExecute
197+ ) ;
198+
199+ System . Diagnostics . Process . Start (
200+ new System . Diagnostics . ProcessStartInfo
201+ {
202+ FileName = "/usr/bin/env" ,
203+ Arguments = $ "bash \" { updateScriptPath } \" ",
204+ UseShellExecute = false ,
205+ CreateNoWindow = true ,
206+ }
207+ ) ;
208+
209+ App . Shutdown ( ) ;
210+ return ;
211+ }
212+ catch ( Exception ex )
213+ {
214+ logger . LogError ( ex , "Failed to execute AppImage update script" ) ;
190215
191- File . SetUnixFileMode (
192- updateScriptPath ,
193- UnixFileMode . UserRead | UnixFileMode . UserWrite | UnixFileMode . UserExecute
194- ) ;
216+ var dialog = DialogHelper . CreateMarkdownDialog (
217+ "AppImage update script failed. \n Could not replace old AppImage with new version. Please check directory permissions. \n Falling back to standard update process. User intervention required: After program closes, \n please move the new AppImage extracted in the '.StabilityMatrixUpdate' hidden directory to the old AppImage overwriting it. \n \n Close this dialog to continue with standard update process." ,
218+ Resources . Label_UnexpectedErrorOccurred
219+ ) ;
195220
196- System . Diagnostics . Process . Start (
197- new System . Diagnostics . ProcessStartInfo
198- {
199- FileName = "/bin/bash" ,
200- Arguments = updateScriptPath ,
201- UseShellExecute = false ,
202- CreateNoWindow = true ,
203- }
204- ) ;
205-
206- App . Shutdown ( ) ;
207- return ;
221+ await dialog . ShowAsync ( ) ;
222+ }
208223 }
209224
210225 // Set current version for update messages
0 commit comments