From f2243d355c9cf9fe55cdd8f84550ab4e130b383f Mon Sep 17 00:00:00 2001 From: Hannah Lynn Lindrob Date: Thu, 19 Feb 2026 12:36:59 +0100 Subject: [PATCH 1/2] update unzip function --- .../src/main/java/dev/slimevr/updater/Linux.kt | 15 ++++++++++++--- .../src/main/java/dev/slimevr/updater/Main.kt | 2 +- .../main/java/dev/slimevr/updater/UpdaterUtils.kt | 14 +++++++------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/updater/desktop/src/main/java/dev/slimevr/updater/Linux.kt b/updater/desktop/src/main/java/dev/slimevr/updater/Linux.kt index 12b39e9b8..fb8079ca4 100644 --- a/updater/desktop/src/main/java/dev/slimevr/updater/Linux.kt +++ b/updater/desktop/src/main/java/dev/slimevr/updater/Linux.kt @@ -8,7 +8,12 @@ class Linux { val path = Paths.get("").toAbsolutePath().toString() + var steamVRDriverSuccess = false + var udevSuccess = false + var feederSuccess = false + fun updateLinux() { + removeLinuxSteamVRDriver() updateLinuxSteamVRDriver() updateUdev() feeder() @@ -24,7 +29,7 @@ class Linux { subProgressBar.isVisible = true val vrPathRegContents = executeShellCommand("${System.getProperty("user.home")}/.steam/steam/steamapps/common/SteamVR/bin/vrpathreg.sh") val isDriverRegistered = vrPathRegContents.contains("slimevr") - if (isDriverRegistered) { + if (!isDriverRegistered) { subProgressBar.string = "Downloading SteamVR Driver" downloadFile(LINUXSTEAMVRDRIVERURL, LINUXSTEAMVRDRIVERNAME) subProgressBar.string = "Unzipping SteamVR Driver" @@ -42,6 +47,7 @@ class Linux { } subProgressBar.string = "SteamVR Driver done" mainProgressBar.value = (100 / 3) + steamVRDriverSuccess = true } fun removeLinuxSteamVRDriver() { @@ -63,13 +69,15 @@ class Linux { mainProgressBar.string = "Updating Feeder app" subProgressBar.string = "Downloading Feeder App" subProgressBar.isVisible = true - // downloadFile(LINUXFEEDERURL, LINUXFEEDERNAME) + downloadFile(LINUXFEEDERURL, LINUXFEEDERNAME) subProgressBar.string = "Unzipping Feeder App" unzip(LINUXFEEDERNAME, LINUXFEEDERDIRECTORY) subProgressBar.string = "Registering Feeder App" - executeShellCommand("$path/$LINUXFEEDERDIRECTORY/SlimeVR-Feeder-App", "--install") + println(executeShellCommand("chmod", "+x", "$path/$LINUXFEEDERDIRECTORY/$LINUXFEEDERDIRECTORY/SlimeVR-Feeder-App")) + println(executeShellCommand("$path/$LINUXFEEDERDIRECTORY/$LINUXFEEDERDIRECTORY/SlimeVR-Feeder-App", "--install")) mainProgressBar.value = (100 / 3 * 3) subProgressBar.string = "Feeder app done" + feederSuccess = true } // TODO: Find a way to do version checking on udev rules @@ -91,6 +99,7 @@ class Linux { mainProgressBar.value = (100 / 3 * 2) subProgressBar.value = 100 subProgressBar.string = "Udev done" + udevSuccess = true } companion object { diff --git a/updater/desktop/src/main/java/dev/slimevr/updater/Main.kt b/updater/desktop/src/main/java/dev/slimevr/updater/Main.kt index f412d6e28..b1d92d32d 100644 --- a/updater/desktop/src/main/java/dev/slimevr/updater/Main.kt +++ b/updater/desktop/src/main/java/dev/slimevr/updater/Main.kt @@ -14,7 +14,7 @@ val mainProgressPanel = JPanel() val mainProgressBar = JProgressBar() val subProgressPanel = JPanel() val subProgressBar = JProgressBar() -val isUpdateSuccessFull = false +val isUpdateSuccessFull = true val VERSION = (GIT_VERSION_TAG.ifEmpty { GIT_COMMIT_HASH }) + diff --git a/updater/desktop/src/main/java/dev/slimevr/updater/UpdaterUtils.kt b/updater/desktop/src/main/java/dev/slimevr/updater/UpdaterUtils.kt index 71ef3ea7b..023f18bfc 100644 --- a/updater/desktop/src/main/java/dev/slimevr/updater/UpdaterUtils.kt +++ b/updater/desktop/src/main/java/dev/slimevr/updater/UpdaterUtils.kt @@ -23,7 +23,6 @@ import java.nio.file.Paths import java.security.MessageDigest import java.util.zip.ZipEntry import java.util.zip.ZipFile -import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds fun executeShellCommand(vararg command: String): String = try { @@ -84,7 +83,7 @@ fun downloadFile( } // Guard against zip slip -fun newFile(destinationPath: File, zipEntry: ZipEntry): File { +fun resolveSaveFile(destinationPath: File, zipEntry: ZipEntry): File { val destFile = File(destinationPath, zipEntry.name) val destinationDirPath = destinationPath.getCanonicalPath() @@ -103,7 +102,10 @@ fun unzip( onProgress: (Float) -> Unit = sendProgress, ) { onProgress(0f) - val destFile = File(destDir) + val destFolder = File(destDir) + if (!destFolder.exists()) { + destFolder.mkdirs() + } val zipFile = ZipFile(file) val dataBuffer = ByteArray(1024) try { @@ -113,7 +115,7 @@ fun unzip( while (zipEntries.hasMoreElements()) { val currentEntry = zipEntries.nextElement() val inputStream = zipFile.getInputStream(currentEntry) - val file = newFile(destFile, currentEntry) + val file = resolveSaveFile(destFolder, currentEntry) if (currentEntry.isDirectory) { if (!file.isDirectory && !file.mkdirs()) { throw IOException("Failed to create directory: $file") @@ -124,6 +126,7 @@ fun unzip( } } } else { + file.parentFile?.mkdirs() val fileOutputStream = FileOutputStream(file) var len = inputStream.read(dataBuffer, 0, 1024) while (len > 0) { @@ -135,12 +138,9 @@ fun unzip( onProgress(currentEntryCount.toFloat() / zipSize.toFloat() * 100) currentEntryCount++ } - - deleteFile(destFile) } catch (e: Exception) { println("Error during unzip: ${e.message}") label.text = "An error occurred: ${e.message}" - deleteFile(destFile) } } From 2dd8fd966738aca05f3a0b15711b8fdf099fd4f3 Mon Sep 17 00:00:00 2001 From: Hannah Lynn Lindrob Date: Thu, 19 Feb 2026 14:54:37 +0100 Subject: [PATCH 2/2] update electron to launch updater --- gui/electron/main/index.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index b1017ffa8..a9b45fd0b 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -369,20 +369,6 @@ const spawnServer = async () => { const updater = spawn(javaBin, ['-Xmx128M', '-jar', updaterJar, 'run']); - updater.stdout?.on('data', (message) => { - mainWindow?.webContents.send(IPC_CHANNELS.SERVER_STATUS, { - message: message.toString(), - type: 'stdout' - } satisfies ServerStatusEvent) - }); - - updater.stderr?.on('data', (message) => { - mainWindow?.webContents.send(IPC_CHANNELS.SERVER_STATUS, { - message: message.toString(), - type: 'stderr' - } satisfies ServerStatusEvent) - }); - const process = spawn(javaBin, ['-Xmx128M', '-jar', serverJar, 'run']); process.stdout?.on('data', (message) => {