@@ -10,7 +10,7 @@ public static void Upgrade(string fileName)
10
10
{
11
11
Console . WriteLine ( $ "{ Resx . Resource . StartUnzipping } \n { fileName } ") ;
12
12
13
- Waiting ( 5 ) ;
13
+ Utils . Waiting ( 5 ) ;
14
14
15
15
if ( ! File . Exists ( fileName ) )
16
16
{
@@ -42,12 +42,12 @@ public static void Upgrade(string fileName)
42
42
StringBuilder sb = new ( ) ;
43
43
try
44
44
{
45
- string thisAppOldFile = $ "{ Utils . GetExePath ( ) } .tmp";
45
+ var thisAppOldFile = $ "{ Utils . GetExePath ( ) } .tmp";
46
46
File . Delete ( thisAppOldFile ) ;
47
- string splitKey = "/" ;
47
+ var splitKey = "/" ;
48
48
49
- using ZipArchive archive = ZipFile . OpenRead ( fileName ) ;
50
- foreach ( ZipArchiveEntry entry in archive . Entries )
49
+ using var archive = ZipFile . OpenRead ( fileName ) ;
50
+ foreach ( var entry in archive . Entries )
51
51
{
52
52
try
53
53
{
@@ -60,15 +60,20 @@ public static void Upgrade(string fileName)
60
60
61
61
var lst = entry . FullName . Split ( splitKey ) ;
62
62
if ( lst . Length == 1 ) continue ;
63
- string fullName = string . Join ( splitKey , lst [ 1 ..lst . Length ] ) ;
63
+ var fullName = string . Join ( splitKey , lst [ 1 ..lst . Length ] ) ;
64
64
65
65
if ( string . Equals ( Utils . GetExePath ( ) , Utils . GetPath ( fullName ) , StringComparison . OrdinalIgnoreCase ) )
66
66
{
67
67
File . Move ( Utils . GetExePath ( ) , thisAppOldFile ) ;
68
68
}
69
69
70
- string entryOutputPath = Utils . GetPath ( fullName ) ;
70
+ var entryOutputPath = Utils . GetPath ( fullName ) ;
71
71
Directory . CreateDirectory ( Path . GetDirectoryName ( entryOutputPath ) ! ) ;
72
+ //In the bin folder, if the file already exists, it will be skipped
73
+ if ( fullName . StartsWith ( "bin" ) && File . Exists ( entryOutputPath ) )
74
+ {
75
+ continue ;
76
+ }
72
77
entry . ExtractToFile ( entryOutputPath , true ) ;
73
78
74
79
Console . WriteLine ( entryOutputPath ) ;
@@ -91,18 +96,9 @@ public static void Upgrade(string fileName)
91
96
}
92
97
93
98
Console . WriteLine ( Resx . Resource . Restartv2rayN ) ;
94
- Waiting ( 2 ) ;
99
+ Utils . Waiting ( 2 ) ;
95
100
96
101
Utils . StartV2RayN ( ) ;
97
102
}
98
-
99
- public static void Waiting ( int second )
100
- {
101
- for ( var i = second ; i > 0 ; i -- )
102
- {
103
- Console . WriteLine ( i ) ;
104
- Thread . Sleep ( 1000 ) ;
105
- }
106
- }
107
103
}
108
104
}
0 commit comments