@@ -11,26 +11,28 @@ class Autoupdater extends require('../../lib/BaseModule')
1111{
1212 MODULE_NAME = "autoupdate" ;
1313 EXECUTABLE_NAME = "" ;
14+ DOWNLOAD_PATH = "" ;
1415
1516 setup_linux ( )
1617 {
1718 this . EXECUTABLE_NAME = app . app_info . app_executable ;
19+ this . DOWNLOAD_PATH = app . getPath ( "downloads" ) ;
1820
1921 // You can control this behavior:
2022 autoUpdater . autoDownload = ( this . getAppData ( ) . auto_downalod == true ) ; // ask first
2123 autoUpdater . autoInstallOnAppQuit = true ; // install after app closes
2224
23- this . log ( 'Checking for updates...' ) ;
24- autoUpdater . checkForUpdates ( ) ;
25-
2625 if ( ! process . env . APPIMAGE )
2726 {
2827 this . warn ( "process.env.APPIMAGE not assigned: this is not an AppImage!" ) ;
2928 return ;
3029 }
30+ this . log ( 'Checking for updates...' ) ;
31+ autoUpdater . checkForUpdates ( ) ;
32+
3133 autoUpdater . on ( 'update-available' , info => {
32- this . log ( `Update available: ${ info . version } ` ) ;
33- dialog . showMessageBox ( this . window , {
34+ this . log ( `Update available: ${ info . version } ` ) ;
35+ dialog . showMessageBox ( this . window , {
3436 type : 'info' ,
3537 title : 'Update Available' ,
3638 message : `Version ${ info . version } is available. Download now?` ,
@@ -51,19 +53,20 @@ class Autoupdater extends require('../../lib/BaseModule')
5153 } ) ;
5254
5355 autoUpdater . on ( 'update-downloaded' , info => {
54- this . log ( 'Update downloaded, will install now.' ) ;
55- dialog . showMessageBox ( this . window , {
56- title : 'Install Update' ,
57- message : 'Update downloaded. The app will restart to install.'
58- } ) . then ( ( ) => {
59- const exec_bin_location = path . join ( HOME_BIN_LINUX , this . EXECUTABLE_NAME ) ;
60- const newFile = path . join ( path . dirname ( process . env . APPIMAGE ) , this . EXECUTABLE_NAME + `-${ info . version } .AppImage` ) ;
61- this . log ( "Linking new version:" , info . version , "to" , newFile , "at" , exec_bin_location ) ;
62- fs . existsSync ( newFile ) &&
63- exec ( `ln -sf "${ newFile } " "${ exec_bin_location } "` ) ;
64- this . log ( "Installing" ) ;
65- // autoUpdater.quitAndInstall();
66- } )
56+ // dialog.showMessageBox(this.window, {
57+ // type: 'info',
58+ // title: 'Install Update',
59+ // message: 'Update downloaded. Quit app to install.',
60+ // buttons: ['Quit app']
61+ // }).then(() => {
62+ this . log ( "Linking executable..." )
63+ const exec_bin_location = path . join ( HOME_BIN_LINUX , this . EXECUTABLE_NAME ) ;
64+ const newFile = path . join ( this . DOWNLOAD_PATH , this . EXECUTABLE_NAME + `-${ info . version } .AppImage` ) ;
65+ this . log ( "Linking new version:" , info . version , "to" , newFile , "at" , exec_bin_location ) ;
66+ if ( fs . existsSync ( newFile ) )
67+ fs . symlinkSync ( newFile , exec_bin_location ) ;
68+ this . log ( "Installing" ) ;
69+ autoUpdater . quitAndInstall ( ) ;
6770 } ) ;
6871
6972 autoUpdater . on ( 'update-not-available' , ( ) => {
0 commit comments