Skip to content

Commit 4c3c1e0

Browse files
committed
Optimization and upgrade tools
1 parent c27651b commit 4c3c1e0

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

v2rayN/AmazTool/UpgradeApp.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,7 @@ public static void Upgrade(string fileName)
7979
continue;
8080
}
8181

82-
try
83-
{
84-
entry.ExtractToFile(entryOutputPath, true);
85-
}
86-
catch
87-
{
88-
Thread.Sleep(1000);
89-
entry.ExtractToFile(entryOutputPath, true);
90-
}
82+
TryExtractToFile(entry, entryOutputPath);
9183

9284
Console.WriteLine(entryOutputPath);
9385
}
@@ -113,4 +105,24 @@ public static void Upgrade(string fileName)
113105

114106
Utils.StartV2RayN();
115107
}
108+
109+
private static bool TryExtractToFile(ZipArchiveEntry entry, string outputPath)
110+
{
111+
var retryCount = 5;
112+
var delayMs = 1000;
113+
114+
for (var i = 1; i <= retryCount; i++)
115+
{
116+
try
117+
{
118+
entry.ExtractToFile(outputPath, true);
119+
return true;
120+
}
121+
catch
122+
{
123+
Thread.Sleep(delayMs * i);
124+
}
125+
}
126+
return false;
127+
}
116128
}

0 commit comments

Comments
 (0)