Skip to content

Commit 5d932d6

Browse files
committed
add version.txt to skip checking and releasing
1 parent 9c108df commit 5d932d6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/main/java/io/vproxy/jdkman/Main.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.*;
1717

1818
public class Main {
19-
private static final String VERSION = "1.0.2";
19+
public static final String VERSION = "1.0.2";
2020
private static final String HELP_STR = """
2121
Usage:
2222
jdkman [action] [options]

src/main/java/io/vproxy/jdkman/action/InitAction.java

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.vproxy.base.util.Logger;
55
import io.vproxy.base.util.OS;
66
import io.vproxy.base.util.Utils;
7+
import io.vproxy.jdkman.Main;
78
import io.vproxy.jdkman.entity.JDKManConfig;
89
import io.vproxy.jdkman.ex.ErrorResult;
910
import io.vproxy.jdkman.res.ResConsts;
@@ -42,6 +43,7 @@ public class InitAction implements Action {
4243
"javaws", "jcontrol", "jweblauncher"
4344
));
4445
}};
46+
private static final String VERSION_FILE = "version.txt";
4547

4648
@Override
4749
public String validate(String[] options) {
@@ -70,6 +72,14 @@ public boolean execute(JDKManConfig config, String[] options) throws Exception {
7072
}
7173

7274
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+
}
7383

7484
for (var exe : EXECUTABLES) {
7585
var suffix = "";
@@ -83,6 +93,10 @@ public boolean execute(JDKManConfig config, String[] options) throws Exception {
8393
Logger.error(LogType.INVALID_EXTERNAL_DATA, STR."\{file} is not a valid file");
8494
continue;
8595
}
96+
if (versionMatches) {
97+
// no need to release the file because version matches
98+
continue;
99+
}
86100
if (OS.isWindows()) {
87101
// check file md5 for windows, because windows doesn't allow files to be deleted while they are running
88102
var md5 = io.vproxy.jdkman.util.Utils.fileMD5(file);
@@ -113,6 +127,8 @@ public boolean execute(JDKManConfig config, String[] options) throws Exception {
113127
}
114128
}
115129

130+
Files.writeString(versionFilePath, Main.VERSION);
131+
116132
var scriptToEval = getScriptToEval(jdkmanScriptDir, shellType);
117133
System.out.println(scriptToEval.trim());
118134

0 commit comments

Comments
 (0)