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