4
4
import io .vproxy .base .util .Logger ;
5
5
import io .vproxy .base .util .OS ;
6
6
import io .vproxy .base .util .Utils ;
7
+ import io .vproxy .jdkman .Main ;
7
8
import io .vproxy .jdkman .entity .JDKManConfig ;
8
9
import io .vproxy .jdkman .ex .ErrorResult ;
9
10
import io .vproxy .jdkman .res .ResConsts ;
@@ -42,6 +43,7 @@ public class InitAction implements Action {
42
43
"javaws" , "jcontrol" , "jweblauncher"
43
44
));
44
45
}};
46
+ private static final String VERSION_FILE = "version.txt" ;
45
47
46
48
@ Override
47
49
public String validate (String [] options ) {
@@ -70,6 +72,14 @@ public boolean execute(JDKManConfig config, String[] options) throws Exception {
70
72
}
71
73
72
74
var jdkmanScriptDir = jdkmanScriptPathFile ();
75
+ var versionFilePath = Path .of (jdkmanScriptDir .getAbsolutePath (), VERSION_FILE );
76
+ boolean versionMatches = false ;
77
+ if (versionFilePath .toFile ().isFile ()) {
78
+ var version = Files .readString (versionFilePath ).trim ();
79
+ if (version .equals (Main .VERSION )) {
80
+ versionMatches = true ;
81
+ }
82
+ }
73
83
74
84
for (var exe : EXECUTABLES ) {
75
85
var suffix = "" ;
@@ -83,6 +93,10 @@ public boolean execute(JDKManConfig config, String[] options) throws Exception {
83
93
Logger .error (LogType .INVALID_EXTERNAL_DATA , STR ."\{file } is not a valid file" );
84
94
continue ;
85
95
}
96
+ if (versionMatches ) {
97
+ // no need to release the file because version matches
98
+ continue ;
99
+ }
86
100
if (OS .isWindows ()) {
87
101
// check file md5 for windows, because windows doesn't allow files to be deleted while they are running
88
102
var md5 = io .vproxy .jdkman .util .Utils .fileMD5 (file );
@@ -113,6 +127,8 @@ public boolean execute(JDKManConfig config, String[] options) throws Exception {
113
127
}
114
128
}
115
129
130
+ Files .writeString (versionFilePath , Main .VERSION );
131
+
116
132
var scriptToEval = getScriptToEval (jdkmanScriptDir , shellType );
117
133
System .out .println (scriptToEval .trim ());
118
134
0 commit comments