@@ -563,14 +563,19 @@ private async void AutoUpdateThread()
563563
564564 public void EnableInstallMenuItem ( )
565565 {
566- this . installNewVersionToolStripMenuItem . Visible = true ;
567- this . installNewVersionToolStripMenuItem . Enabled = true ;
568- if ( CheckDownloadedNewVersion ( ) )
566+ if ( ! this . installNewVersionToolStripMenuItem . Visible ) {
567+ this . installNewVersionToolStripMenuItem . Visible = true ;
568+ }
569+ if ( ! this . installNewVersionToolStripMenuItem . Enabled )
569570 {
570- string log_output = "found verified installer" ;
571- logWindow . Write_to_log_fromThread ( log_output ) ;
572- this . installNewVersionToolStripMenuItem . Text = LocRM . GetString ( "String180" ) ;
573- newVersionDownloaded = true ;
571+ this . installNewVersionToolStripMenuItem . Enabled = true ;
572+ if ( CheckDownloadedNewVersion ( ) )
573+ {
574+ string log_output = "found verified installer" ;
575+ logWindow . Write_to_log_fromThread ( log_output ) ;
576+ this . installNewVersionToolStripMenuItem . Text = LocRM . GetString ( "String180" ) ;
577+ newVersionDownloaded = true ;
578+ }
574579 }
575580 }
576581
@@ -2413,6 +2418,18 @@ private bool CheckDownloadedNewVersion()
24132418 return r ;
24142419 }
24152420
2421+ private void SetDownloadProgress ( int value )
2422+ {
2423+ Object [ ] values = { value } ;
2424+ Progress . currentProgress . SetProgress2_fromThread ( values ) ;
2425+ }
2426+
2427+ private void SetDownloadText ( string text )
2428+ {
2429+ Object [ ] values = { text } ;
2430+ doTimeTable . Progress . currentProgress . ShowText_fromThread ( values ) ;
2431+ }
2432+
24162433 private async void DownloadNewVersion ( )
24172434 {
24182435 string log_output ;
@@ -2423,6 +2440,9 @@ private async void DownloadNewVersion()
24232440 {
24242441 if ( httpClient != null )
24252442 {
2443+ Progress . currentProgress . Show ( ) ;
2444+ Progress . currentProgress . ActivateMe ( Progress . Type . DOWNLOAD ) ;
2445+
24262446 string localNewVersion = "" ;
24272447#if DEBUG
24282448 Version lv = new Version ( version ) ;
@@ -2441,9 +2461,9 @@ private async void DownloadNewVersion()
24412461 newVersion = crypto . newVersion ;
24422462 }
24432463
2444- string installerName = "doTimeTableSetup.msi" ;
2464+ // string installerName = "doTimeTableSetup.msi";
24452465 string newInstallerName = "doTimeTableSetup-" + newVersion + ".msi" ;
2446- string downloadURL = "https://raw.githubusercontent. com/oheil/doTimeTable/v" + newVersion + "/src/ " + installerName ;
2466+ string downloadURL = "https://github. com/oheil/doTimeTable/releases/download/ v" + newVersion + "/" + newInstallerName ;
24472467 if ( System . IO . File . Exists ( downloadPath + Path . DirectorySeparatorChar + newInstallerName ) )
24482468 {
24492469 try
@@ -2482,14 +2502,26 @@ private async void DownloadNewVersion()
24822502 CheckDownloadedNewVersion ( ) ;
24832503 }
24842504#endif
2505+ SetDownloadProgress ( 10 ) ;
2506+ SetDownloadText ( LocRM . GetString ( "String186" ) + " " + newInstallerName ) ;
2507+ log_output = "Downloading " + newInstallerName ;
2508+ Form1 . logWindow . Write_to_log ( ref log_output ) ;
24852509 if ( ! System . IO . File . Exists ( downloadPath + Path . DirectorySeparatorChar + newInstallerName ) )
24862510 {
24872511 try
24882512 {
24892513 HttpResponseMessage response = await httpClient . GetAsync ( new Uri ( downloadURL ) ) ;
2490- using ( var fs = new FileStream ( downloadPath + Path . DirectorySeparatorChar + newInstallerName , FileMode . Create ) )
2514+ if ( response . IsSuccessStatusCode )
2515+ {
2516+ using ( var fs = new FileStream ( downloadPath + Path . DirectorySeparatorChar + newInstallerName , FileMode . Create ) )
2517+ {
2518+ await response . Content . CopyToAsync ( fs ) ;
2519+ }
2520+ }
2521+ else
24912522 {
2492- await response . Content . CopyToAsync ( fs ) ;
2523+ log_output = "Download " + newInstallerName + " failed" ;
2524+ Form1 . logWindow . Write_to_log ( ref log_output ) ;
24932525 }
24942526 }
24952527 catch ( Exception ex )
@@ -2498,14 +2530,26 @@ private async void DownloadNewVersion()
24982530 Form1 . logWindow . Write_to_log ( ref log_output ) ;
24992531 }
25002532 }
2533+ SetDownloadProgress ( 70 ) ;
2534+ SetDownloadText ( LocRM . GetString ( "String186" ) + " " + newInstallerName + ".sha256" ) ;
2535+ log_output = "Downloading " + newInstallerName + ".sha256" ;
2536+ Form1 . logWindow . Write_to_log ( ref log_output ) ;
25012537 if ( ! System . IO . File . Exists ( downloadPath + Path . DirectorySeparatorChar + newInstallerName + ".sha256" ) )
25022538 {
25032539 try
25042540 {
25052541 HttpResponseMessage response = await httpClient . GetAsync ( new Uri ( downloadURL + ".sha256" ) ) ;
2506- using ( var fs = new FileStream ( downloadPath + Path . DirectorySeparatorChar + newInstallerName + ".sha256" , FileMode . Create ) )
2542+ if ( response . IsSuccessStatusCode )
25072543 {
2508- await response . Content . CopyToAsync ( fs ) ;
2544+ using ( var fs = new FileStream ( downloadPath + Path . DirectorySeparatorChar + newInstallerName + ".sha256" , FileMode . Create ) )
2545+ {
2546+ await response . Content . CopyToAsync ( fs ) ;
2547+ }
2548+ }
2549+ else
2550+ {
2551+ log_output = "Download " + newInstallerName + ".sha256" + " failed" ;
2552+ Form1 . logWindow . Write_to_log ( ref log_output ) ;
25092553 }
25102554 }
25112555 catch ( Exception ex )
@@ -2514,6 +2558,10 @@ private async void DownloadNewVersion()
25142558 Form1 . logWindow . Write_to_log ( ref log_output ) ;
25152559 }
25162560 }
2561+ SetDownloadProgress ( 80 ) ;
2562+ SetDownloadText ( LocRM . GetString ( "String189" ) ) ;
2563+ log_output = "Verifying " + newInstallerName ;
2564+ Form1 . logWindow . Write_to_log ( ref log_output ) ;
25172565 if ( CheckDownloadedNewVersion ( ) && System . IO . File . Exists ( downloadPath + Path . DirectorySeparatorChar + newInstallerName ) )
25182566 {
25192567 log_output = "downloaded and verified installer: " + downloadPath + Path . DirectorySeparatorChar + newInstallerName ;
@@ -2526,12 +2574,15 @@ private async void DownloadNewVersion()
25262574 log_output = "error: installer could not be downloaded or verified" ;
25272575 Form1 . logWindow . Write_to_log ( ref log_output ) ;
25282576 }
2577+ SetDownloadProgress ( 100 ) ;
25292578 }
25302579 else
25312580 {
25322581 log_output = "error: new version unknown" ;
25332582 Form1 . logWindow . Write_to_log ( ref log_output ) ;
25342583 }
2584+
2585+ Progress . currentProgress . Julia_ready_fromThread ( ) ;
25352586 }
25362587 }
25372588 else
0 commit comments