Skip to content

Commit a9aeecd

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into UpdateJson
2 parents a0c4cc3 + fb18869 commit a9aeecd

File tree

56 files changed

+295
-1034
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+295
-1034
lines changed
File renamed without changes.

Flow.Launcher.Core/Updater.cs

Lines changed: 43 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -30,86 +30,65 @@ public Updater(string gitHubRepository)
3030

3131
public async Task UpdateApp(IPublicAPI api, bool silentUpdate = true)
3232
{
33-
UpdateManager updateManager;
34-
UpdateInfo newUpdateInfo;
35-
36-
if (!silentUpdate)
37-
api.ShowMsg("Please wait...", "Checking for new update");
38-
3933
try
4034
{
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+
4842

49-
try
50-
{
5143
// UpdateApp CheckForUpdate will return value only if the app is squirrel installed
5244
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-
}
6045

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);
6348

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()}>");
7350

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+
}
7657

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...");
8760

88-
await updateManager.ApplyReleases(newUpdateInfo).ConfigureAwait(false);
61+
await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply).ConfigureAwait(false);
8962

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);
10264

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+
}
10477

105-
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
78+
var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());
10679

107-
// always dispose UpdateManager
108-
updateManager.Dispose();
80+
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
10981

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)
11188
{
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;
11392
}
11493
}
11594

Flow.Launcher.Infrastructure/Constant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static class Constant
3030

3131
public static string PythonPath;
3232

33-
public static readonly string QueryTextBoxIconImagePath = $"{ProgramDirectory}\\Images\\mainsearch.png";
33+
public static readonly string QueryTextBoxIconImagePath = $"{ProgramDirectory}\\Images\\mainsearch.svg";
3434

3535
public const string DefaultTheme = "Darker";
3636

Flow.Launcher.Infrastructure/Http/Http.cs

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,31 @@ public static void UpdateProxy(ProxyProperty property)
7575
};
7676
}
7777

78-
public static async Task Download([NotNull] string url, [NotNull] string filePath)
78+
public static async Task DownloadAsync([NotNull] string url, [NotNull] string filePath)
7979
{
80-
using var response = await client.GetAsync(url);
81-
if (response.StatusCode == HttpStatusCode.OK)
80+
try
8281
{
83-
await using var fileStream = new FileStream(filePath, FileMode.CreateNew);
84-
await response.Content.CopyToAsync(fileStream);
82+
using var response = await client.GetAsync(url);
83+
if (response.StatusCode == HttpStatusCode.OK)
84+
{
85+
await using var fileStream = new FileStream(filePath, FileMode.CreateNew);
86+
await response.Content.CopyToAsync(fileStream);
87+
}
88+
else
89+
{
90+
throw new HttpRequestException($"Error code <{response.StatusCode}> returned from <{url}>");
91+
}
8592
}
86-
else
93+
catch (HttpRequestException e)
8794
{
88-
throw new HttpRequestException($"Error code <{response.StatusCode}> returned from <{url}>");
95+
Log.Exception("Infrastructure.Http", "Http Request Error", e, "DownloadAsync");
96+
throw;
8997
}
9098
}
9199

92100
/// <summary>
93101
/// Asynchrously get the result as string from url.
94-
/// When supposing the result is long and large, try using GetStreamAsync to avoid reading as string
102+
/// When supposing the result larger than 83kb, try using GetStreamAsync to avoid reading as string
95103
/// </summary>
96104
/// <param name="url"></param>
97105
/// <returns></returns>
@@ -101,19 +109,33 @@ public static Task<string> GetAsync([NotNull] string url)
101109
return GetAsync(new Uri(url.Replace("#", "%23")));
102110
}
103111

112+
/// <summary>
113+
/// Asynchrously get the result as string from url.
114+
/// When supposing the result larger than 83kb, try using GetStreamAsync to avoid reading as string
115+
/// </summary>
116+
/// <param name="url"></param>
117+
/// <returns></returns>
104118
public static async Task<string> GetAsync([NotNull] Uri url)
105119
{
106120
Log.Debug($"|Http.Get|Url <{url}>");
107-
using var response = await client.GetAsync(url);
108-
var content = await response.Content.ReadAsStringAsync();
109-
if (response.StatusCode == HttpStatusCode.OK)
121+
try
110122
{
111-
return content;
123+
using var response = await client.GetAsync(url);
124+
var content = await response.Content.ReadAsStringAsync();
125+
if (response.StatusCode == HttpStatusCode.OK)
126+
{
127+
return content;
128+
}
129+
else
130+
{
131+
throw new HttpRequestException(
132+
$"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>");
133+
}
112134
}
113-
else
135+
catch (HttpRequestException e)
114136
{
115-
throw new HttpRequestException(
116-
$"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>");
137+
Log.Exception("Infrastructure.Http", "Http Request Error", e, "GetAsync");
138+
throw;
117139
}
118140
}
119141

@@ -124,9 +146,17 @@ public static async Task<string> GetAsync([NotNull] Uri url)
124146
/// <returns></returns>
125147
public static async Task<Stream> GetStreamAsync([NotNull] string url)
126148
{
127-
Log.Debug($"|Http.Get|Url <{url}>");
128-
var response = await client.GetAsync(url);
129-
return await response.Content.ReadAsStreamAsync();
149+
try
150+
{
151+
Log.Debug($"|Http.Get|Url <{url}>");
152+
var response = await client.GetAsync(url);
153+
return await response.Content.ReadAsStreamAsync();
154+
}
155+
catch (HttpRequestException e)
156+
{
157+
Log.Exception("Infrastructure.Http", "Http Request Error", e, "GetStreamAsync");
158+
throw;
159+
}
130160
}
131161
}
132162
}

Flow.Launcher.sln

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher", "Flow.Launc
2020
{F9C4C081-4CC3-4146-95F1-E102B4E10A5F} = {F9C4C081-4CC3-4146-95F1-E102B4E10A5F}
2121
{59BD9891-3837-438A-958D-ADC7F91F6F7E} = {59BD9891-3837-438A-958D-ADC7F91F6F7E}
2222
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0}
23-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567} = {F35190AA-4758-4D9E-A193-E3BDF6AD3567}
2423
{9B130CC5-14FB-41FF-B310-0A95B6894C37} = {9B130CC5-14FB-41FF-B310-0A95B6894C37}
2524
{FDED22C8-B637-42E8-824A-63B5B6E05A3A} = {FDED22C8-B637-42E8-824A-63B5B6E05A3A}
2625
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {A3DCCBCA-ACC1-421D-B16E-210896234C26}
@@ -44,8 +43,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Sys",
4443
EndProject
4544
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Url", "Plugins\Flow.Launcher.Plugin.Url\Flow.Launcher.Plugin.Url.csproj", "{A3DCCBCA-ACC1-421D-B16E-210896234C26}"
4645
EndProject
47-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Color", "Plugins\Flow.Launcher.Plugin.Color\Flow.Launcher.Plugin.Color.csproj", "{F35190AA-4758-4D9E-A193-E3BDF6AD3567}"
48-
EndProject
4946
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FFD651C7-0546-441F-BC8C-D4EE8FD01EA7}"
5047
ProjectSection(SolutionItems) = preProject
5148
.gitattributes = .gitattributes
@@ -214,18 +211,6 @@ Global
214211
{A3DCCBCA-ACC1-421D-B16E-210896234C26}.Release|x64.Build.0 = Release|Any CPU
215212
{A3DCCBCA-ACC1-421D-B16E-210896234C26}.Release|x86.ActiveCfg = Release|Any CPU
216213
{A3DCCBCA-ACC1-421D-B16E-210896234C26}.Release|x86.Build.0 = Release|Any CPU
217-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
218-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Debug|Any CPU.Build.0 = Debug|Any CPU
219-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Debug|x64.ActiveCfg = Debug|Any CPU
220-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Debug|x64.Build.0 = Debug|Any CPU
221-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Debug|x86.ActiveCfg = Debug|Any CPU
222-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Debug|x86.Build.0 = Debug|Any CPU
223-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|Any CPU.ActiveCfg = Release|Any CPU
224-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|Any CPU.Build.0 = Release|Any CPU
225-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|x64.ActiveCfg = Release|Any CPU
226-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|x64.Build.0 = Release|Any CPU
227-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|x86.ActiveCfg = Release|Any CPU
228-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567}.Release|x86.Build.0 = Release|Any CPU
229214
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
230215
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
231216
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -309,7 +294,6 @@ Global
309294
{FDED22C8-B637-42E8-824A-63B5B6E05A3A} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
310295
{0B9DE348-9361-4940-ADB6-F5953BFFCCEC} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
311296
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
312-
{F35190AA-4758-4D9E-A193-E3BDF6AD3567} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
313297
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
314298
{9B130CC5-14FB-41FF-B310-0A95B6894C37} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
315299
{59BD9891-3837-438A-958D-ADC7F91F6F7E} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}

0 commit comments

Comments
 (0)