Skip to content

Commit b924a79

Browse files
authored
Merge pull request #2798 from Flow-Launcher/prerelease
Semantic Version
2 parents 8e942c0 + 1cce95e commit b924a79

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

Flow.Launcher.Core/Flow.Launcher.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<PackageReference Include="FSharp.Core" Version="9.0.201" />
5858
<PackageReference Include="Meziantou.Framework.Win32.Jobs" Version="3.4.0" />
5959
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
60+
<PackageReference Include="SemanticVersioning" Version="3.0.0" />
6061
<PackageReference Include="squirrel.windows" Version="1.5.2" NoWarn="NU1701" />
6162
<PackageReference Include="StreamJsonRpc" Version="2.21.10" />
6263
</ItemGroup>

Flow.Launcher.Core/Updater.cs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ public async Task UpdateAppAsync(bool silentUpdate = true)
4949
// UpdateApp CheckForUpdate will return value only if the app is squirrel installed
5050
var newUpdateInfo = await updateManager.CheckForUpdate().NonNull().ConfigureAwait(false);
5151

52-
var newReleaseVersion = Version.Parse(newUpdateInfo.FutureReleaseEntry.Version.ToString());
53-
var currentVersion = Version.Parse(Constant.Version);
52+
var newReleaseVersion =
53+
SemanticVersioning.Version.Parse(newUpdateInfo.FutureReleaseEntry.Version.ToString());
54+
var currentVersion = SemanticVersioning.Version.Parse(Constant.Version);
5455

5556
_api.LogInfo(ClassName, $"Future Release <{Formatted(newUpdateInfo.FutureReleaseEntry)}>");
5657

@@ -71,10 +72,13 @@ public async Task UpdateAppAsync(bool silentUpdate = true)
7172

7273
if (DataLocation.PortableDataLocationInUse())
7374
{
74-
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion}\\{DataLocation.PortableFolderName}";
75+
var targetDestination = updateManager.RootAppDirectory +
76+
$"\\app-{newReleaseVersion}\\{DataLocation.PortableFolderName}";
7577
FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination, (s) => _api.ShowMsgBox(s));
76-
if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination, (s) => _api.ShowMsgBox(s)))
77-
_api.ShowMsgBox(string.Format(_api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
78+
if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination,
79+
(s) => _api.ShowMsgBox(s)))
80+
_api.ShowMsgBox(string.Format(
81+
_api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
7882
DataLocation.PortableDataPath,
7983
targetDestination));
8084
}
@@ -87,22 +91,25 @@ public async Task UpdateAppAsync(bool silentUpdate = true)
8791

8892
_api.LogInfo(ClassName, $"Update success:{newVersionTips}");
8993

90-
if (_api.ShowMsgBox(newVersionTips, _api.GetTranslation("update_flowlauncher_new_update"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
94+
if (_api.ShowMsgBox(newVersionTips, _api.GetTranslation("update_flowlauncher_new_update"),
95+
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
9196
{
9297
UpdateManager.RestartApp(Constant.ApplicationFileName);
9398
}
9499
}
95100
catch (Exception e)
96101
{
97-
if (e is HttpRequestException or WebException or SocketException || e.InnerException is TimeoutException)
102+
if (e is HttpRequestException or WebException or SocketException ||
103+
e.InnerException is TimeoutException)
98104
{
99-
_api.LogException(ClassName, $"Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
105+
_api.LogException(ClassName,
106+
$"Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
100107
}
101108
else
102109
{
103110
_api.LogException(ClassName, $"Error Occurred", e);
104111
}
105-
112+
106113
if (!silentUpdate)
107114
_api.ShowMsg(_api.GetTranslation("update_flowlauncher_fail"),
108115
_api.GetTranslation("update_flowlauncher_check_connection"));
@@ -116,14 +123,11 @@ public async Task UpdateAppAsync(bool silentUpdate = true)
116123
[UsedImplicitly]
117124
private class GithubRelease
118125
{
119-
[JsonPropertyName("prerelease")]
120-
public bool Prerelease { get; [UsedImplicitly] set; }
126+
[JsonPropertyName("prerelease")] public bool Prerelease { get; [UsedImplicitly] set; }
121127

122-
[JsonPropertyName("published_at")]
123-
public DateTime PublishedAt { get; [UsedImplicitly] set; }
128+
[JsonPropertyName("published_at")] public DateTime PublishedAt { get; [UsedImplicitly] set; }
124129

125-
[JsonPropertyName("html_url")]
126-
public string HtmlUrl { get; [UsedImplicitly] set; }
130+
[JsonPropertyName("html_url")] public string HtmlUrl { get; [UsedImplicitly] set; }
127131
}
128132

129133
// https://github.com/Squirrel/Squirrel.Windows/blob/master/src/Squirrel/UpdateManager.Factory.cs
@@ -138,10 +142,7 @@ private static async Task<UpdateManager> GitHubUpdateManagerAsync(string reposit
138142
var latest = releases.Where(r => !r.Prerelease).OrderByDescending(r => r.PublishedAt).First();
139143
var latestUrl = latest.HtmlUrl.Replace("/tag/", "/download/");
140144

141-
var client = new WebClient
142-
{
143-
Proxy = Http.WebProxy
144-
};
145+
var client = new WebClient { Proxy = Http.WebProxy };
145146
var downloader = new FileDownloader(client);
146147

147148
var manager = new UpdateManager(latestUrl, urlDownloader: downloader);
@@ -158,10 +159,7 @@ private string NewVersionTips(string version)
158159

159160
private static string Formatted<T>(T t)
160161
{
161-
var formatted = JsonSerializer.Serialize(t, new JsonSerializerOptions
162-
{
163-
WriteIndented = true
164-
});
162+
var formatted = JsonSerializer.Serialize(t, new JsonSerializerOptions { WriteIndented = true });
165163

166164
return formatted;
167165
}

0 commit comments

Comments
 (0)