From dde1fb0498ea887e366f3bea9bc2a0127b96359d Mon Sep 17 00:00:00 2001 From: Saptarshi Sarkar Date: Thu, 15 Feb 2024 16:20:01 +0530 Subject: [PATCH] fix: Fixed permissions error in macos in Drifty gui --- GUI/src/main/java/ui/UIController.java | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/GUI/src/main/java/ui/UIController.java b/GUI/src/main/java/ui/UIController.java index 15d332b42..275cf9594 100644 --- a/GUI/src/main/java/ui/UIController.java +++ b/GUI/src/main/java/ui/UIController.java @@ -112,18 +112,21 @@ private void downloadUpdate() { setDir(customDirectory); if (OS.isMac()) { try { - ProcessBuilder extractPkg = new ProcessBuilder("pkgutil", "--expand", Paths.get(tmpFolder.toString(), currentExecutablePath.getFileName().toString()).toAbsolutePath().toString(), Paths.get(tmpFolder.toString(), "Drifty GUI").toAbsolutePath().toString()); - Process pkgExtractProcess = extractPkg.start(); - pkgExtractProcess.waitFor(); - ProcessBuilder extractPayload = new ProcessBuilder("tar", "-xvf", Paths.get(tmpFolder.toString(), "Drifty GUI", "GUI-app.pkg", "Payload").toAbsolutePath().toString(), "-C", Paths.get(tmpFolder.toString(), "Drifty GUI", "Payload_Contents").toAbsolutePath().toString()); - Process payloadExtractProcess = extractPayload.start(); - payloadExtractProcess.waitFor(); - File latestExecutable = Paths.get(tmpFolder.toString(), "Drifty GUI", "Payload_Contents", "GUI.app").toAbsolutePath().toFile(); - ExecuteUpdate updateExecutor = new ExecuteUpdate(currentExecutable, latestExecutable); - if (!Mode.isGUI()) { - updateExecutor.setExecutablePermission(); - } - updateExecutor.executeUpdate(); + ProcessBuilder startPkg = new ProcessBuilder("open", Paths.get(tmpFolder.toString(), currentExecutablePath.getFileName().toString()).toAbsolutePath().toString()); + startPkg.start(); + System.exit(0); +// ProcessBuilder extractPkg = new ProcessBuilder("pkgutil", "--expand", Paths.get(tmpFolder.toString(), currentExecutablePath.getFileName().toString()).toAbsolutePath().toString(), Paths.get(tmpFolder.toString(), "Drifty GUI").toAbsolutePath().toString()); +// Process pkgExtractProcess = extractPkg.start(); +// pkgExtractProcess.waitFor(); +// ProcessBuilder extractPayload = new ProcessBuilder("tar", "-xvf", Paths.get(tmpFolder.toString(), "Drifty GUI", "GUI-app.pkg", "Payload").toAbsolutePath().toString(), "-C", Paths.get(tmpFolder.toString(), "Drifty GUI", "Payload_Contents").toAbsolutePath().toString()); +// Process payloadExtractProcess = extractPayload.start(); +// payloadExtractProcess.waitFor(); +// File latestExecutable = Paths.get(tmpFolder.toString(), "Drifty GUI", "Payload_Contents", "GUI.app").toAbsolutePath().toFile(); +// ExecuteUpdate updateExecutor = new ExecuteUpdate(currentExecutable, latestExecutable); +// if (!Mode.isGUI()) { +// updateExecutor.setExecutablePermission(); +// } +// updateExecutor.executeUpdate(); } catch (SecurityException e) { M.msgUpdateError("Failed to extract the latest executable due to security restrictions! " + e.getMessage()); } catch (UnsupportedOperationException e) {