This commit is contained in:
2022-06-03 22:38:20 +03:00
parent 0d524cdf65
commit 8fcd33e734

View File

@@ -1,7 +1,6 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using PluginManager.Online;
using PluginManager.Others;
using System.Threading.Tasks;
@@ -16,6 +15,7 @@ namespace DiscordBotGUI
public partial class AppUpdater : Window
{
private string _version;
public AppUpdater()
{
InitializeComponent();
@@ -27,7 +27,6 @@ namespace DiscordBotGUI
if (!File.Exists("./DiscordBot.exe")) DownloadDiscordBotClientNoGUIAsDLL();
Updates();
}
private async void DownloadDiscordBotClientNoGUIAsDLL()
@@ -88,10 +87,7 @@ namespace DiscordBotGUI
return;
}
IProgress<float> progress = new Progress<float>((percent) =>
{
this.progressBar1.Value = percent;
});
IProgress<float> progress = new Progress<float>((percent) => { this.progressBar1.Value = percent; });
textBox1.Text = "Extracting update files ...";
await Functions.ExtractArchive(file, "./", progress);
@@ -102,7 +98,6 @@ namespace DiscordBotGUI
await Task.Delay(5000);
new MainWindow() { Height = 425, Width = 650 }.Show();
this.Close();
}
private async Task<string> DownloadNewUpdate()
@@ -130,7 +125,6 @@ namespace DiscordBotGUI
string FileName = $"{urlNewUpdateZip.Split('/')[urlNewUpdateZip.Split('/').Length - 1]}";
try
{
new Thread(new Task(() =>
{
while (isDownloading)
@@ -148,6 +142,7 @@ namespace DiscordBotGUI
await Task.Delay(1000);
return null;
}
isDownloading = false;
return FileName;
}
@@ -156,14 +151,10 @@ namespace DiscordBotGUI
{
try
{
string current_version = Functions.readCodeFromFile("Version.txt", "DiscordBotVersion", '=') ?? "0";
string latest_version = (await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/Version"))[0];
_version = latest_version;
if (current_version != latest_version)
{
return true;
}
if (current_version != latest_version) { return true; }
return false;
}