Remove installers sdk archive when archive fails

This will allow the next run to redownload the file.
This commit is contained in:
Luke 2022-11-24 16:19:39 +10:00
parent 403677fad2
commit e561158699

View file

@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.Tar;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine($"TShock Installer {typeof(Program).Assembly.GetName().Version}.");
// reference: https://github.com/dotnet/install-scripts/blob/main/src/dotnet-install.sh
@ -65,6 +66,8 @@ var tshock_path = "TShock.Server" + (is_targz ? "" : ".exe");
if (!File.Exists(dotnet_path))
{
try
{
Console.WriteLine("Extracting to ./dotnet/");
if (is_targz)
{
@ -83,6 +86,18 @@ if (!File.Exists(dotnet_path))
{
ZipFile.ExtractToDirectory(filename, "dotnet");
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine($"Failed to extract {filename}. The archive will be removed. Restart the installer to begin the download again.");
Console.Error.WriteLine(ex);
if (File.Exists(filename))
File.Delete(filename);
return;
}
}
else
{