@@ -222,14 +222,28 @@ private static async Task CheckKnetUpdates()
222222 GitHubReleaseAsset ? releaseAsset = null ;
223223 foreach ( GitHubReleaseAsset a in latest . assets )
224224 {
225- if ( a . name != null && ( a . name . ToLower ( ) . Contains ( ".zip" ) || a . name . ToLower ( ) . Contains ( ".7z" ) || a . name . ToLower ( ) . Contains ( ".tar.gz" ) ) )
225+ if ( KnUtils . IsAppImage )
226226 {
227- if ( a . name . ToLower ( ) . Contains ( KnUtils . GetOSNameString ( ) . ToLower ( ) ) )
227+ if ( a . name != null )
228228 {
229- if ( a . name . ToLower ( ) . Contains ( KnUtils . CpuArch . ToLower ( ) ) && ( KnUtils . CpuArch != "Arm" || KnUtils . CpuArch == "Arm " && ! a . name . ToLower ( ) . Contains ( "arm64 ") ) )
229+ if ( ( KnUtils . CpuArch . ToLower ( ) == "x64" && a . name . EndsWith ( "x86_64.AppImage" ) ) || ( KnUtils . CpuArch . ToLower ( ) == "arm64 " && a . name . EndsWith ( "aarch64.AppImage ") ) )
230230 {
231231 releaseAsset = a ;
232- continue ;
232+ break ;
233+ }
234+ }
235+ }
236+ else
237+ {
238+ if ( a . name != null && ( a . name . ToLower ( ) . Contains ( ".zip" ) || a . name . ToLower ( ) . Contains ( ".7z" ) || a . name . ToLower ( ) . Contains ( ".tar.gz" ) ) )
239+ {
240+ if ( a . name . ToLower ( ) . Contains ( KnUtils . GetOSNameString ( ) . ToLower ( ) ) )
241+ {
242+ if ( a . name . ToLower ( ) . Contains ( KnUtils . CpuArch . ToLower ( ) ) && ( KnUtils . CpuArch != "Arm" || KnUtils . CpuArch == "Arm" && ! a . name . ToLower ( ) . Contains ( "arm64" ) ) )
243+ {
244+ releaseAsset = a ;
245+ continue ;
246+ }
233247 }
234248 }
235249 }
@@ -256,6 +270,11 @@ private static async Task CheckKnetUpdates()
256270 //Rename files in app folder
257271 var appDirPath = System . AppDomain . CurrentDomain . BaseDirectory ;
258272 var execName = System . Diagnostics . Process . GetCurrentProcess ( ) . MainModule ! . FileName ;
273+ if ( KnUtils . IsAppImage )
274+ {
275+ // change exec name to be the AppImage itself (is full path!)
276+ execName = KnUtils . AppImagePath ;
277+ }
259278 File . Move ( execName ! , execName + ".old" , true ) ;
260279 if ( KnUtils . IsWindows )
261280 {
@@ -275,7 +294,7 @@ private static async Task CheckKnetUpdates()
275294 }
276295 catch { }
277296 }
278- if ( KnUtils . IsLinux )
297+ if ( KnUtils . IsLinux && ! KnUtils . IsAppImage )
279298 {
280299 try
281300 {
@@ -310,51 +329,77 @@ private static async Task CheckKnetUpdates()
310329 //Decompress new files
311330 try
312331 {
313- using ( var archive = ArchiveFactory . Open ( KnUtils . GetKnossosDataFolderPath ( ) + Path . DirectorySeparatorChar + "update" + extension ) )
332+ // no extraction needed for AppImage, just move exec over and restart
333+ // NOTE: exeName is already the full path to the AppImage
334+ if ( KnUtils . IsAppImage )
314335 {
315- try
316- {
317- var reader = archive . ExtractAllEntries ( ) ;
318- while ( reader . MoveToNextEntry ( ) )
319- {
320- if ( ! reader . Entry . IsDirectory )
321- {
322- reader . WriteEntryToDirectory ( appDirPath ! , new ExtractionOptions ( ) { ExtractFullPath = false , Overwrite = true } ) ;
323- }
324- }
325- }
326- catch ( Exception ex )
327- {
328- Log . Add ( Log . LogSeverity . Error , "Knossos.CheckKnetUpdates()" , ex ) ;
329- }
336+ File . Move ( KnUtils . GetKnossosDataFolderPath ( ) + Path . DirectorySeparatorChar + "update" + extension , execName ! ) ;
330337
331338 //Start again
332339 try
333340 {
334- if ( KnUtils . IsMacOS || KnUtils . IsLinux )
335- {
336- KnUtils . Chmod ( Path . Combine ( appDirPath , execName ! ) , "+x" ) ;
337- }
341+ KnUtils . Chmod ( execName ! , "+x" ) ;
342+
338343 Process p = new Process ( ) ;
339- p . StartInfo . FileName = Path . Combine ( appDirPath , execName ! ) ;
344+ p . StartInfo . FileName = execName ! ;
340345 p . Start ( ) ;
341346 }
342347 catch ( Exception ex )
343348 {
344349 Log . Add ( Log . LogSeverity . Error , "Knossos.CheckKnetUpdates()" , ex ) ;
345350 }
346351
347- //Cleanup file
348- try
349- {
350- if ( File . Exists ( KnUtils . GetKnossosDataFolderPath ( ) + Path . DirectorySeparatorChar + "update" + extension ) )
351- File . Delete ( KnUtils . GetKnossosDataFolderPath ( ) + Path . DirectorySeparatorChar + "update" + extension ) ;
352- }
353- catch { }
354-
355352 //Close App
356353 MainWindow . instance ! . Close ( ) ;
357354 }
355+ else
356+ {
357+ using ( var archive = ArchiveFactory . Open ( KnUtils . GetKnossosDataFolderPath ( ) + Path . DirectorySeparatorChar + "update" + extension ) )
358+ {
359+ try
360+ {
361+ var reader = archive . ExtractAllEntries ( ) ;
362+ while ( reader . MoveToNextEntry ( ) )
363+ {
364+ if ( ! reader . Entry . IsDirectory )
365+ {
366+ reader . WriteEntryToDirectory ( appDirPath ! , new ExtractionOptions ( ) { ExtractFullPath = false , Overwrite = true } ) ;
367+ }
368+ }
369+ }
370+ catch ( Exception ex )
371+ {
372+ Log . Add ( Log . LogSeverity . Error , "Knossos.CheckKnetUpdates()" , ex ) ;
373+ }
374+
375+ //Start again
376+ try
377+ {
378+ if ( KnUtils . IsMacOS || KnUtils . IsLinux )
379+ {
380+ KnUtils . Chmod ( Path . Combine ( appDirPath , execName ! ) , "+x" ) ;
381+ }
382+ Process p = new Process ( ) ;
383+ p . StartInfo . FileName = Path . Combine ( appDirPath , execName ! ) ;
384+ p . Start ( ) ;
385+ }
386+ catch ( Exception ex )
387+ {
388+ Log . Add ( Log . LogSeverity . Error , "Knossos.CheckKnetUpdates()" , ex ) ;
389+ }
390+
391+ //Cleanup file
392+ try
393+ {
394+ if ( File . Exists ( KnUtils . GetKnossosDataFolderPath ( ) + Path . DirectorySeparatorChar + "update" + extension ) )
395+ File . Delete ( KnUtils . GetKnossosDataFolderPath ( ) + Path . DirectorySeparatorChar + "update" + extension ) ;
396+ }
397+ catch { }
398+
399+ //Close App
400+ MainWindow . instance ! . Close ( ) ;
401+ }
402+ }
358403 } catch ( Exception ex )
359404 {
360405 //Rollback
@@ -381,7 +426,7 @@ private static async Task CheckKnetUpdates()
381426 }
382427 catch { }
383428 }
384- if ( KnUtils . IsLinux )
429+ if ( KnUtils . IsLinux && ! KnUtils . IsAppImage )
385430 {
386431 try
387432 {
0 commit comments