File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments