@@ -31,86 +31,65 @@ public Updater(string gitHubRepository)
31
31
32
32
public async Task UpdateApp ( IPublicAPI api , bool silentUpdate = true )
33
33
{
34
- UpdateManager updateManager ;
35
- UpdateInfo newUpdateInfo ;
36
-
37
- if ( ! silentUpdate )
38
- api . ShowMsg ( "Please wait..." , "Checking for new update" ) ;
39
-
40
34
try
41
35
{
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
+
49
43
50
- try
51
- {
52
44
// UpdateApp CheckForUpdate will return value only if the app is squirrel installed
53
45
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
- }
61
46
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 ) ;
64
49
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 ( ) } >") ;
74
51
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
+ }
77
58
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..." ) ;
88
61
89
- await updateManager . ApplyReleases ( newUpdateInfo ) . ConfigureAwait ( false ) ;
62
+ await updateManager . DownloadReleases ( newUpdateInfo . ReleasesToApply ) . ConfigureAwait ( false ) ;
90
63
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 ) ;
103
65
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
+ }
105
78
106
- Log . Info ( $ "|Updater.UpdateApp|Update success: { newVersionTips } " ) ;
79
+ var newVersionTips = NewVersinoTips ( newReleaseVersion . ToString ( ) ) ;
107
80
108
- // always dispose UpdateManager
109
- updateManager . Dispose ( ) ;
81
+ Log . Info ( $ "|Updater.UpdateApp|Update success:{ newVersionTips } ") ;
110
82
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 )
112
89
{
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 ;
114
93
}
115
94
}
116
95
0 commit comments