From d0d8932e744c65056d30205dd7fc6ac2654c7a90 Mon Sep 17 00:00:00 2001 From: rpanic Date: Wed, 30 Jan 2019 09:36:59 +0100 Subject: [PATCH] Added automatic resource extracting for new versions --- src/main/kotlin/Main.kt | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index 16a676e..8ef46ff 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -21,6 +21,8 @@ fun main(args: Array) { class Main{ + val frontend_version = "1.0.1"; + var map = HashMap() val path = "/filedata/" @@ -67,7 +69,7 @@ class Main{ if(url.endsWith("/")) url = url.substring(0, url.length - 1) - extractResource("frontend") + extractFrontend("frontend") loadEditors() @@ -302,11 +304,23 @@ class Main{ return sslContextFactory } - fun extractResource(path: String) { + fun extractFrontend(path: String) { - var root = File(userdir() + "/frontend") + var root = File(userdir() + "/" + path) if(root.isDirectory && root.exists()){ - return + + var versionfile = File(root.path + "/frontend.version") + + if(versionfile.exists()) { + var version = versionfile.readLines().joinToString() + + if (version.equals(frontend_version)) { + return + } else { + println("New version detected: Switching frontend from $version to $frontend_version") + root.deleteRecursively() + } + } } val jarFile = File(javaClass.protectionDomain.codeSource.location.path) @@ -338,7 +352,7 @@ class Main{ // for (app in apps.listFiles()) { // System.out.println(app) // if (app.isDirectory) { -// extractResource(path + "/" + app.name) +// extractFrontend(path + "/" + app.name) // } else { // if(!app.parentFile.exists()) // app.parentFile.mkdir()