Remove installers sdk archive when archive fails
This will allow the next run to redownload the file.
This commit is contained in:
parent
403677fad2
commit
e561158699
1 changed files with 26 additions and 11 deletions
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue