Skip to content

Commit

Permalink
Don't double download
Browse files Browse the repository at this point in the history
Having 2 checks is fine, but we don't need 2 download attempts as well.
  • Loading branch information
Zacam committed Feb 14, 2021
1 parent d1df0dc commit 1b83b30
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
3 changes: 1 addition & 2 deletions GameLauncherUpdater/GameLauncherUpdater.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -81,7 +81,6 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="App\SimpleJSON.cs" />
<EmbeddedResource Include="Updater.resx">
<DependentUpon>Updater.cs</DependentUpon>
</EmbeddedResource>
Expand Down
28 changes: 14 additions & 14 deletions GameLauncherUpdater/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Net;
using System.Windows.Forms;
using System.IO.Compression;
using ZipFile = System.IO.Compression.ZipFile;
//using ZipFile = System.IO.Compression.ZipFile;
using System.Threading;
using SimpleJSON;
//using SimpleJSON;
using System.Web.Script.Serialization;
using GameLauncherUpdater.App;

Expand Down Expand Up @@ -55,7 +55,7 @@ public void DoUpdate()
}

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

/*
var client = new WebClient();
Uri StringToUri = new Uri("https://api.worldunited.gg/update.php?version=" + version);
client.Headers.Add("user-agent", "GameLauncherUpdater " + Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)");
Expand Down Expand Up @@ -88,14 +88,14 @@ public void DoUpdate()
{
Information.Text = "Failed to Connect to Main API --> Connecting to GitHub API";
}
};
};*/

var client3 = new WebClient();
Uri StringToUri2 = new Uri("https://api.github.com/repos/SoapboxRaceWorld/GameLauncher_NFSW/releases/latest");
client3.Headers.Add("user-agent", "GameLauncherUpdater " + Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)");
client3.CancelAsync();
client3.DownloadStringAsync(StringToUri2);
client3.DownloadStringCompleted += (sender3, e3) =>
var client = new WebClient();
Uri StringToUri = new Uri("https://api.github.com/repos/SoapboxRaceWorld/GameLauncher_NFSW/releases/latest");
client.Headers.Add("user-agent", "GameLauncherUpdater " + Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)");
client.CancelAsync();
client.DownloadStringAsync(StringToUri);
client.DownloadStringCompleted += (sender3, e3) =>
{
try
{
Expand All @@ -105,10 +105,10 @@ public void DoUpdate()
{
Thread thread = new Thread(() =>
{
WebClient client4 = new WebClient();
client4.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Client_DownloadProgressChanged);
client4.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
client4.DownloadFileAsync(new Uri("http://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases/download/" + json.tag_name + "/Release_" + json.tag_name + ".zip"), tempNameZip);
WebClient client2 = new WebClient();
client2.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Client_DownloadProgressChanged);
client2.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
client2.DownloadFileAsync(new Uri("http://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases/download/" + json.tag_name + "/Release_" + json.tag_name + ".zip"), tempNameZip);
});
thread.Start();
}
Expand Down

0 comments on commit 1b83b30

Please sign in to comment.