Skip to content

Commit

Permalink
fix: Fixed permissions error in macos in Drifty gui
Browse files Browse the repository at this point in the history
  • Loading branch information
SaptarshiSarkar12 committed Feb 15, 2024
1 parent 5471f2b commit dde1fb0
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions GUI/src/main/java/ui/UIController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit dde1fb0

Please sign in to comment.