@@ -31,86 +31,65 @@ public Updater(string gitHubRepository)
3131
3232 public async Task UpdateApp ( IPublicAPI api , bool silentUpdate = true )
3333 {
34- UpdateManager updateManager ;
35- UpdateInfo newUpdateInfo ;
36-
37- if ( ! silentUpdate )
38- api . ShowMsg ( "Please wait..." , "Checking for new update" ) ;
39-
4034 try
4135 {
42- updateManager = await GitHubUpdateManager ( GitHubRepository ) . ConfigureAwait ( false ) ;
43- }
44- catch ( Exception e ) when ( e is HttpRequestException || e is WebException || e is SocketException )
45- {
46- Log . Exception ( $ "|Updater.UpdateApp|Please check your connection and proxy settings to api.github.com." , e ) ;
47- return ;
48- }
36+ UpdateInfo newUpdateInfo ;
37+
38+ if ( ! silentUpdate )
39+ api . ShowMsg ( "Please wait..." , "Checking for new update" ) ;
40+
41+ using var updateManager = await GitHubUpdateManager ( GitHubRepository ) . ConfigureAwait ( false ) ;
42+
4943
50- try
51- {
5244 // UpdateApp CheckForUpdate will return value only if the app is squirrel installed
5345 newUpdateInfo = await updateManager . CheckForUpdate ( ) . NonNull ( ) . ConfigureAwait ( false ) ;
54- }
55- catch ( Exception e ) when ( e is HttpRequestException || e is WebException || e is SocketException )
56- {
57- Log . Exception ( $ "|Updater.UpdateApp|Check your connection and proxy settings to api.github.com.", e ) ;
58- updateManager . Dispose ( ) ;
59- return ;
60- }
6146
62- var newReleaseVersion = Version . Parse ( newUpdateInfo . FutureReleaseEntry . Version . ToString ( ) ) ;
63- var currentVersion = Version . Parse ( Constant . Version ) ;
47+ var newReleaseVersion = Version . Parse ( newUpdateInfo . FutureReleaseEntry . Version . ToString ( ) ) ;
48+ var currentVersion = Version . Parse ( Constant . Version ) ;
6449
65- Log . Info ( $ "|Updater.UpdateApp|Future Release <{ newUpdateInfo . FutureReleaseEntry . Formatted ( ) } >") ;
66-
67- if ( newReleaseVersion <= currentVersion )
68- {
69- if ( ! silentUpdate )
70- MessageBox . Show ( "You already have the latest Flow Launcher version" ) ;
71- updateManager . Dispose ( ) ;
72- return ;
73- }
50+ Log . Info ( $ "|Updater.UpdateApp|Future Release <{ newUpdateInfo . FutureReleaseEntry . Formatted ( ) } >") ;
7451
75- if ( ! silentUpdate )
76- api . ShowMsg ( "Update found" , "Updating..." ) ;
52+ if ( newReleaseVersion <= currentVersion )
53+ {
54+ if ( ! silentUpdate )
55+ MessageBox . Show ( "You already have the latest Flow Launcher version" ) ;
56+ return ;
57+ }
7758
78- try
79- {
80- await updateManager . DownloadReleases ( newUpdateInfo . ReleasesToApply ) ;
81- }
82- catch ( Exception e ) when ( e is HttpRequestException || e is WebException || e is SocketException )
83- {
84- Log . Exception ( $ "|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e ) ;
85- updateManager . Dispose ( ) ;
86- return ;
87- }
59+ if ( ! silentUpdate )
60+ api . ShowMsg ( "Update found" , "Updating..." ) ;
8861
89- await updateManager . ApplyReleases ( newUpdateInfo ) . ConfigureAwait ( false ) ;
62+ await updateManager . DownloadReleases ( newUpdateInfo . ReleasesToApply ) . ConfigureAwait ( false ) ;
9063
91- if ( DataLocation . PortableDataLocationInUse ( ) )
92- {
93- var targetDestination = updateManager . RootAppDirectory + $ "\\ app-{ newReleaseVersion . ToString ( ) } \\ { DataLocation . PortableFolderName } ";
94- FilesFolders . CopyAll ( DataLocation . PortableDataPath , targetDestination ) ;
95- if ( ! FilesFolders . VerifyBothFolderFilesEqual ( DataLocation . PortableDataPath , targetDestination ) )
96- MessageBox . Show ( "Flow Launcher was not able to move your user profile data to the new update version. Please manually " +
97- $ "move your profile data folder from { DataLocation . PortableDataPath } to { targetDestination } ") ;
98- }
99- else
100- {
101- await updateManager . CreateUninstallerRegistryEntry ( ) . ConfigureAwait ( false ) ;
102- }
64+ await updateManager . ApplyReleases ( newUpdateInfo ) . ConfigureAwait ( false ) ;
10365
104- var newVersionTips = NewVersinoTips ( newReleaseVersion . ToString ( ) ) ;
66+ if ( DataLocation . PortableDataLocationInUse ( ) )
67+ {
68+ var targetDestination = updateManager . RootAppDirectory + $ "\\ app-{ newReleaseVersion . ToString ( ) } \\ { DataLocation . PortableFolderName } ";
69+ FilesFolders . CopyAll ( DataLocation . PortableDataPath , targetDestination ) ;
70+ if ( ! FilesFolders . VerifyBothFolderFilesEqual ( DataLocation . PortableDataPath , targetDestination ) )
71+ MessageBox . Show ( "Flow Launcher was not able to move your user profile data to the new update version. Please manually " +
72+ $ "move your profile data folder from { DataLocation . PortableDataPath } to { targetDestination } ") ;
73+ }
74+ else
75+ {
76+ await updateManager . CreateUninstallerRegistryEntry ( ) . ConfigureAwait ( false ) ;
77+ }
10578
106- Log . Info ( $ "|Updater.UpdateApp|Update success: { newVersionTips } " ) ;
79+ var newVersionTips = NewVersinoTips ( newReleaseVersion . ToString ( ) ) ;
10780
108- // always dispose UpdateManager
109- updateManager . Dispose ( ) ;
81+ Log . Info ( $ "|Updater.UpdateApp|Update success:{ newVersionTips } ") ;
11082
111- if ( MessageBox . Show ( newVersionTips , "New Update" , MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
83+ if ( MessageBox . Show ( newVersionTips , "New Update" , MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
84+ {
85+ UpdateManager . RestartApp ( Constant . ApplicationFileName ) ;
86+ }
87+ }
88+ catch ( Exception e ) when ( e is HttpRequestException || e is WebException || e is SocketException )
11289 {
113- UpdateManager . RestartApp ( Constant . ApplicationFileName ) ;
90+ Log . Exception ( $ "|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e ) ;
91+ api . ShowMsg ( "Update Failed" , "Check your connection and try updating proxy settings to github-cloud.s3.amazonaws.com." ) ;
92+ return ;
11493 }
11594 }
11695
0 commit comments