Simplify: read version only from JAR manifest, remove .version file

This commit is contained in:
SashegDev
2026-05-08 15:09:59 +00:00
parent 659265c2f0
commit 13c9f67f6e
@@ -24,10 +24,6 @@ public class Bootstrap {
private static Path getLauncherJar() { private static Path getLauncherJar() {
return binDir.resolve(JAR_NAME); return binDir.resolve(JAR_NAME);
} }
private static Path getVersionFile() {
return binDir.resolve(".version");
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
baseDir = Paths.get("").toAbsolutePath(); baseDir = Paths.get("").toAbsolutePath();
@@ -75,15 +71,6 @@ public class Bootstrap {
} }
private static String readCurrentVersion() { private static String readCurrentVersion() {
Path versionFile = getVersionFile();
if (Files.exists(versionFile)) {
try {
String v = Files.readString(versionFile).trim();
if (!v.isBlank()) return v;
} catch (Exception ignored) {}
}
// Fallback: читаем из манифеста JAR
Path jar = getLauncherJar(); Path jar = getLauncherJar();
if (Files.exists(jar)) { if (Files.exists(jar)) {
try (JarFile jarFile = new JarFile(jar.toFile())) { try (JarFile jarFile = new JarFile(jar.toFile())) {
@@ -96,7 +83,6 @@ public class Bootstrap {
log("Ошибка чтения манифеста: " + e.getMessage()); log("Ошибка чтения манифеста: " + e.getMessage());
} }
} }
return "0.0.0"; return "0.0.0";
} }
@@ -157,16 +143,6 @@ public class Bootstrap {
} }
} }
log("JAR скачан: " + Files.size(jarFile) + " bytes"); log("JAR скачан: " + Files.size(jarFile) + " bytes");
// Сохраняем версию в файл
Path versionFile = getVersionFile();
try {
Files.writeString(versionFile, newVersion);
log("Версия сохранена в " + versionFile);
} catch (Exception e) {
log("Ошибка сохранения версии: " + e.getMessage());
}
log("Обновлено до v" + newVersion); log("Обновлено до v" + newVersion);
} else { } else {
throw new IOException("Сервер вернул код: " + conn.getResponseCode()); throw new IOException("Сервер вернул код: " + conn.getResponseCode());