sorted some classes

This commit is contained in:
HorizonCode 2021-05-27 08:59:45 +02:00
parent a4f060debe
commit c14665d8a8
7 changed files with 7 additions and 8 deletions

View File

@ -12,7 +12,7 @@ namespace EZPPClient_Installer
public class DownloadUtil public class DownloadUtil
{ {
public static List<string> FilesToDownload(string pathToEZPP, bool reinstall) public static async Task<List<string>> FilesToDownload(string pathToEZPP, bool reinstall)
{ {
bool directoryExists = Directory.Exists(pathToEZPP); bool directoryExists = Directory.Exists(pathToEZPP);
@ -21,17 +21,16 @@ namespace EZPPClient_Installer
try try
{ {
using (WebClient wc = new WebClient()) using (WebClient wc = new WebClient())
{ {
wc.Headers.Add("user-agent", "EZPPClientInstaller"); wc.Headers.Add("user-agent", "EZPPClientInstaller");
var data = wc.DownloadString("https://new.ez-pp.farm/ezppclient?list"); var data = await wc.DownloadStringTaskAsync("https://new.ez-pp.farm/ezppclient?list&release=" + MainWindow.RELEASESTREAM.ToLower());
string[] dataList = data.Split('\n'); string[] dataList = data.Split('\n');
foreach (string datastring in dataList) foreach (string datastring in dataList)
{ {
if (string.IsNullOrWhiteSpace(datastring)) if (string.IsNullOrWhiteSpace(datastring) || !datastring.Contains("#"))
continue; continue;
string[] se = datastring.Split('#'); string[] se = datastring.Split('#');
string md5 = StripHTML(se[0]); string md5 = StripHTML(se[0]);
string name = StripHTML(se[1]); string name = StripHTML(se[1]);
@ -41,7 +40,7 @@ namespace EZPPClient_Installer
} }
catch (WebException error) catch (WebException error)
{ {
new ContentDialog() _ = new ContentDialog()
{ {
Title = "Oops...", Title = "Oops...",
Content = "A error occurred while trying to fetch all needed Files.\n" + error.Message, Content = "A error occurred while trying to fetch all needed Files.\n" + error.Message,
@ -72,7 +71,7 @@ namespace EZPPClient_Installer
string onlineHash = md5file.MD5; string onlineHash = md5file.MD5;
string pcHash = MD5Util.CalculateMD5(file); string pcHash = MD5Util.CalculateMD5(file);
#if DEBUG #if DEBUG
MessageBox.Show("Filename: " + md5file.getName() + "\nOnline-Hash: " + onlineHash + "\n PC-Hash: " + pcHash); MessageBox.Show("Filename: " + md5file.Name + "\nOnline-Hash: " + onlineHash + "\n PC-Hash: " + pcHash);
#endif #endif
if (!string.Equals(onlineHash, pcHash)) if (!string.Equals(onlineHash, pcHash))
{ {
@ -151,7 +150,7 @@ namespace EZPPClient_Installer
MainWindow.updateProgress(filename + " - " + value.ProgressPercentage + "% - " + Math.Round((averageTransferRate / 1024000D) * 1.8, 2) + "MBit/s", value.ProgressPercentage); MainWindow.updateProgress(filename + " - " + value.ProgressPercentage + "% - " + Math.Round((averageTransferRate / 1024000D) * 1.8, 2) + "MBit/s", value.ProgressPercentage);
}; };
await wc.DownloadFileTaskAsync(@"https://new.ez-pp.farm/ezppclient?file=" + filename, path + @"\" + filename); await wc.DownloadFileTaskAsync(@"https://new.ez-pp.farm/ezppclient?file=" + filename + "&release=" + MainWindow.RELEASESTREAM.ToLower(), path + @"\" + filename); ;
} }
} }
catch (WebException) catch (WebException)