1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Don't overwrite the wrapper files if the version is the same.

This commit is contained in:
Cedric Beust 2016-04-09 08:08:25 -07:00
parent 9351c9f8ce
commit 111343cdeb

View file

@ -166,7 +166,6 @@ public class Main {
boolean isNew = Float.parseFloat(version) * 1000 >= 650; boolean isNew = Float.parseFloat(version) * 1000 >= 650;
String fromZipOutputDir = DISTRIBUTIONS_DIR + File.separator + "kobalt-" + version;
String toZipOutputDir = DISTRIBUTIONS_DIR; String toZipOutputDir = DISTRIBUTIONS_DIR;
Path kobaltJarFile = Paths.get(toZipOutputDir, Path kobaltJarFile = Paths.get(toZipOutputDir,
isNew ? "kobalt-" + wrapperVersion : "", isNew ? "kobalt-" + wrapperVersion : "",
@ -205,8 +204,10 @@ public class Main {
try (BufferedReader bw = new BufferedReader(fw)) { try (BufferedReader bw = new BufferedReader(fw)) {
String installedVersion = bw.readLine(); String installedVersion = bw.readLine();
if (!wrapperVersion.equals(installedVersion)) { if (!wrapperVersion.equals(installedVersion)) {
log(2, " Trying to install a different version " + wrapperVersion + " != " + installedVersion log(2, " Trying to install a different version "
+ wrapperVersion + " != " + installedVersion
+ ", overwriting the installed wrapper"); + ", overwriting the installed wrapper");
installWrapperFiles(version, wrapperVersion);
} else { } else {
log(2, " Trying to install the same version " + wrapperVersion + " == " + installedVersion log(2, " Trying to install the same version " + wrapperVersion + " == " + installedVersion
+ ", not overwriting the installed wrapper"); + ", not overwriting the installed wrapper");
@ -216,10 +217,12 @@ public class Main {
} }
} }
// return kobaltJarFile;
// Copy the wrapper files in the current kobalt/wrapper directory }
//
if (! noOverwrite) { private void installWrapperFiles(String version, String wrapperVersion) throws IOException {
String fromZipOutputDir = DISTRIBUTIONS_DIR + File.separator + "kobalt-" + version;
for (String file : FILES) { for (String file : FILES) {
Path to = Paths.get(file); Path to = Paths.get(file);
to.toFile().getAbsoluteFile().getParentFile().mkdirs(); to.toFile().getAbsoluteFile().getParentFile().mkdirs();
@ -252,9 +255,6 @@ public class Main {
} }
} }
return kobaltJarFile;
}
private void generateKobaltW(Path filePath) throws IOException { private void generateKobaltW(Path filePath) throws IOException {
// //
// For kobaltw: try to generate it with the correct env shebang. If this fails, // For kobaltw: try to generate it with the correct env shebang. If this fails,