When updating the bin folder, skip the file if it already exists.
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled

https://github.com/2dust/v2rayN/issues/6515
This commit is contained in:
2dust 2025-01-17 10:27:29 +08:00
parent 171132be12
commit cf1a8599eb
2 changed files with 22 additions and 17 deletions

View file

@ -10,7 +10,7 @@ namespace AmazTool
{ {
Console.WriteLine($"{Resx.Resource.StartUnzipping}\n{fileName}"); Console.WriteLine($"{Resx.Resource.StartUnzipping}\n{fileName}");
Waiting(5); Utils.Waiting(5);
if (!File.Exists(fileName)) if (!File.Exists(fileName))
{ {
@ -42,12 +42,12 @@ namespace AmazTool
StringBuilder sb = new(); StringBuilder sb = new();
try try
{ {
string thisAppOldFile = $"{Utils.GetExePath()}.tmp"; var thisAppOldFile = $"{Utils.GetExePath()}.tmp";
File.Delete(thisAppOldFile); File.Delete(thisAppOldFile);
string splitKey = "/"; var splitKey = "/";
using ZipArchive archive = ZipFile.OpenRead(fileName); using var archive = ZipFile.OpenRead(fileName);
foreach (ZipArchiveEntry entry in archive.Entries) foreach (var entry in archive.Entries)
{ {
try try
{ {
@ -60,15 +60,20 @@ namespace AmazTool
var lst = entry.FullName.Split(splitKey); var lst = entry.FullName.Split(splitKey);
if (lst.Length == 1) continue; if (lst.Length == 1) continue;
string fullName = string.Join(splitKey, lst[1..lst.Length]); var fullName = string.Join(splitKey, lst[1..lst.Length]);
if (string.Equals(Utils.GetExePath(), Utils.GetPath(fullName), StringComparison.OrdinalIgnoreCase)) if (string.Equals(Utils.GetExePath(), Utils.GetPath(fullName), StringComparison.OrdinalIgnoreCase))
{ {
File.Move(Utils.GetExePath(), thisAppOldFile); File.Move(Utils.GetExePath(), thisAppOldFile);
} }
string entryOutputPath = Utils.GetPath(fullName); var entryOutputPath = Utils.GetPath(fullName);
Directory.CreateDirectory(Path.GetDirectoryName(entryOutputPath)!); Directory.CreateDirectory(Path.GetDirectoryName(entryOutputPath)!);
//In the bin folder, if the file already exists, it will be skipped
if (fullName.StartsWith("bin") && File.Exists(entryOutputPath))
{
continue;
}
entry.ExtractToFile(entryOutputPath, true); entry.ExtractToFile(entryOutputPath, true);
Console.WriteLine(entryOutputPath); Console.WriteLine(entryOutputPath);
@ -91,18 +96,9 @@ namespace AmazTool
} }
Console.WriteLine(Resx.Resource.Restartv2rayN); Console.WriteLine(Resx.Resource.Restartv2rayN);
Waiting(2); Utils.Waiting(2);
Utils.StartV2RayN(); Utils.StartV2RayN();
} }
public static void Waiting(int second)
{
for (var i = second; i > 0; i--)
{
Console.WriteLine(i);
Thread.Sleep(1000);
}
}
} }
} }

View file

@ -39,5 +39,14 @@ namespace AmazTool
}; };
process.Start(); process.Start();
} }
public static void Waiting(int second)
{
for (var i = second; i > 0; i--)
{
Console.WriteLine(i);
Thread.Sleep(1000);
}
}
} }
} }