Skip to content

Commit

Permalink
🔄️ Fixed App Updater
Browse files Browse the repository at this point in the history
  • Loading branch information
valnoxy committed Feb 18, 2024
1 parent 309a916 commit e5f2795
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -403,3 +403,5 @@ FodyWeavers.xsd
# Additional files built by Visual Studio

# End of httpswww.toptal.comdevelopersgitignoreapivisualstudio

GoAwayEdge/Properties/launchSettings.json
2 changes: 1 addition & 1 deletion GoAwayEdge/Common/Configuration.cs
Expand Up @@ -53,7 +53,7 @@ public static bool InitialEnvironment()
{
NoEdgeInstalled = !File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
"Microsoft", "Edge", "Application", "msedge.exe"));
RegistryConfig.SetKey("NoEdgeInstalled", NoEdgeInstalled);
// RegistryConfig.SetKey("NoEdgeInstalled", NoEdgeInstalled);

if (NoEdgeInstalled)
return true;
Expand Down
19 changes: 9 additions & 10 deletions GoAwayEdge/Common/Updater.cs
Expand Up @@ -139,30 +139,28 @@ public static void ModifyIfeoBinary(ModifyAction action)

try
{
var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()!.Location);
var appVersion = Assembly.GetExecutingAssembly().GetName().Version!;
var currentVersion = new Version(appVersion.Major, appVersion.Minor, appVersion.Build);

using var client = new WebClient();
client.Headers.Add("User-Agent", $"GoAwayEdge/{versionInfo.FileVersion} valnoxy.dev");
client.Headers.Add("User-Agent", $"GoAwayEdge/{currentVersion} valnoxy.dev");
var json = client.DownloadString(url);

var releases = JsonConvert.DeserializeObject<GitHubRelease[]>(json);
if (releases is { Length: > 0 })
{
var tagName = Convert.ToString(releases[0].tag_name);
var tagVersion = tagName[1..];
var currentFileVersion = versionInfo.FileVersion;
var parts = currentFileVersion!.Split('.');
var partsResult = string.Join(".", parts.Take(3));
var currentVersion = new Version(partsResult);
var latestVersion = new Version(tagVersion);

if (currentVersion < latestVersion)
return latestVersion.ToString();
}
return null;
}
catch
catch (Exception ex)
{
Console.WriteLine(ex);
return null;
}
}
Expand All @@ -176,10 +174,11 @@ public static bool UpdateClient()

try
{
var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()!.Location);

var appVersion = Assembly.GetExecutingAssembly().GetName().Version!;
var currentVersion = new Version(appVersion.Major, appVersion.Minor, appVersion.Build);

using var client = new WebClient();
client.Headers.Add("User-Agent", $"GoAwayEdge/{versionInfo.FileVersion} valnoxy.dev");
client.Headers.Add("User-Agent", $"GoAwayEdge/{currentVersion} valnoxy.dev");
var json = client.DownloadString(url);

var releases = JsonConvert.DeserializeObject<GitHubRelease[]>(json);
Expand Down
2 changes: 1 addition & 1 deletion GoAwayEdge/GoAwayEdge.csproj
Expand Up @@ -12,7 +12,7 @@
<AssemblyName>GoAwayEdge</AssemblyName>
<Company>Exploitox</Company>
<Authors>valnoxy</Authors>
<Version>1.3.0.126</Version>
<Version>1.3.0.128</Version>
<Copyright>Copyright (c) 2018 - 2024 Exploitox. All rights reserved.</Copyright>
<PackageProjectUrl>https://github.com/valnoxy/GoAwayEdge</PackageProjectUrl>
<RepositoryUrl>https://github.com/valnoxy/GoAwayEdge</RepositoryUrl>
Expand Down
Expand Up @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-02-18T02:59:21.6134777Z;True|2024-02-18T03:50:51.7938224+01:00;True|2024-02-18T03:47:04.2894198+01:00;True|2024-02-18T03:31:00.9829557+01:00;True|2024-02-17T02:35:17.2695873+01:00;True|2024-02-17T02:01:40.6795925+01:00;True|2024-02-17T00:04:43.5488098+01:00;True|2024-02-17T00:04:32.4968950+01:00;True|2024-02-16T23:53:45.9133917+01:00;True|2024-02-16T23:40:32.0208828+01:00;True|2024-02-16T23:39:15.3606349+01:00;True|2024-02-16T18:15:39.5882631+01:00;True|2024-02-12T23:33:08.1942204+01:00;True|2024-02-12T23:25:47.8534710+01:00;True|2024-02-12T23:20:58.9607727+01:00;True|2024-02-12T23:17:25.1971445+01:00;True|2024-02-12T23:08:47.6325045+01:00;True|2023-10-28T21:04:08.1861273+02:00;True|2023-10-28T20:54:15.8911361+02:00;True|2023-10-19T21:25:07.7531500+02:00;True|2023-10-19T00:00:28.0962969+02:00;True|2022-11-13T02:33:03.7406004+01:00;True|2022-11-13T02:19:07.9073988+01:00;True|2022-11-13T02:18:35.3043045+01:00;True|2022-11-12T20:05:07.6366825+01:00;False|2022-11-12T20:04:52.3576134+01:00;True|2022-11-12T19:36:12.8480978+01:00;</History>
<History>True|2024-02-18T16:16:27.0408261Z;True|2024-02-18T17:15:41.3961034+01:00;True|2024-02-18T17:11:58.7761728+01:00;True|2024-02-18T17:08:57.9390623+01:00;True|2024-02-18T17:08:26.6377454+01:00;True|2024-02-18T17:07:45.2050537+01:00;True|2024-02-18T17:05:12.7495146+01:00;True|2024-02-18T17:02:32.4549017+01:00;True|2024-02-18T16:48:25.3074382+01:00;True|2023-10-19T00:00:28.0962969+02:00;True|2022-11-13T02:33:03.7406004+01:00;True|2022-11-13T02:19:07.9073988+01:00;True|2022-11-13T02:18:35.3043045+01:00;True|2022-11-12T20:05:07.6366825+01:00;False|2022-11-12T20:04:52.3576134+01:00;True|2022-11-12T19:36:12.8480978+01:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

0 comments on commit e5f2795

Please sign in to comment.