Skip to content

Commit 3bba25c

Browse files
committed
Merge branch 'develop' into release/1.5.0
2 parents ec5f08f + a2c0353 commit 3bba25c

File tree

5 files changed

+30
-38
lines changed

5 files changed

+30
-38
lines changed

src/main/java/org/cryptomator/linux/autostart/FreedesktopAutoStartService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ public FreedesktopAutoStartService() {
4444
var xdgConfigDirString = Objects.requireNonNullElse(System.getenv("XDG_CONFIG_HOME"), System.getProperty("user.home") + "/.config");
4545
this.autostartFile = Path.of(xdgConfigDirString, "autostart", AUTOSTART_FILENAME);
4646

47-
var execValue = System.getProperty(CMD_PROPERTY);
48-
if (execValue == null) {
49-
LOG.debug("JVM property {} not set, using command path", CMD_PROPERTY);
50-
execValue = ProcessHandle.current().info().command().orElse("");
51-
}
47+
var execValue = System.getProperty(CMD_PROPERTY,"");
5248
this.hasExecValue = !execValue.isBlank();
5349
this.content = CONTENT_TEMPLATE.formatted(execValue, this.getClass().getName());
5450
}

src/main/java/org/cryptomator/linux/quickaccess/DolphinPlaces.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.cryptomator.integrations.common.Priority;
77
import org.cryptomator.integrations.quickaccess.QuickAccessService;
88
import org.cryptomator.integrations.quickaccess.QuickAccessServiceException;
9+
import org.cryptomator.linux.util.SupportUtil;
910
import org.xml.sax.SAXException;
1011

1112
import javax.xml.XMLConstants;
@@ -160,14 +161,6 @@ private int indexOfEntryOpeningTag(String placesContent, int idIndex) {
160161

161162
@CheckAvailability
162163
public static boolean isSupported() {
163-
try {
164-
var nautilusExistsProc = new ProcessBuilder().command("test", "`command -v dolphin`").start();
165-
if (nautilusExistsProc.waitFor(5000, TimeUnit.MILLISECONDS)) {
166-
return nautilusExistsProc.exitValue() == 0;
167-
}
168-
} catch (IOException | InterruptedException e) {
169-
//NO-OP
170-
}
171-
return false;
164+
return SupportUtil.commandExists("dolphin");
172165
}
173166
}

src/main/java/org/cryptomator/linux/quickaccess/NautilusBookmarks.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.cryptomator.integrations.common.Priority;
77
import org.cryptomator.integrations.quickaccess.QuickAccessService;
88
import org.cryptomator.integrations.quickaccess.QuickAccessServiceException;
9+
import org.cryptomator.linux.util.SupportUtil;
910

1011
import java.io.IOException;
1112
import java.nio.charset.StandardCharsets;
@@ -84,14 +85,6 @@ public void remove() throws QuickAccessServiceException {
8485

8586
@CheckAvailability
8687
public static boolean isSupported() {
87-
try {
88-
var nautilusExistsProc = new ProcessBuilder().command("test", "`command -v nautilus`").start();
89-
if (nautilusExistsProc.waitFor(5000, TimeUnit.MILLISECONDS)) {
90-
return nautilusExistsProc.exitValue() == 0;
91-
}
92-
} catch (IOException | InterruptedException e) {
93-
//NO-OP
94-
}
95-
return false;
88+
return SupportUtil.commandExists("nautilus");
9689
}
9790
}

src/main/java/org/cryptomator/linux/revealpath/DBusSendRevealPathService.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.nio.file.Path;
1212
import java.nio.file.attribute.BasicFileAttributes;
1313
import java.util.Arrays;
14-
import java.util.concurrent.CountDownLatch;
1514
import java.util.concurrent.TimeUnit;
1615
import java.util.stream.Collectors;
1716

@@ -60,20 +59,10 @@ public void reveal(Path path) throws RevealFailedException {
6059

6160
@Override
6261
public boolean isSupported() {
63-
CountDownLatch waitBarrier = new CountDownLatch(2);
64-
ProcessBuilder dbusSendExistsBuilder = new ProcessBuilder().command("test", " `command -v dbus-send`");
65-
ProcessBuilder fileManager1ExistsBuilder = createFileManager1Check();
66-
6762
try {
68-
var dbusSendExists = dbusSendExistsBuilder.start();
69-
dbusSendExists.onExit().thenRun(waitBarrier::countDown);
70-
var fileManager1Exists = fileManager1ExistsBuilder.start();
71-
fileManager1Exists.onExit().thenRun(waitBarrier::countDown);
72-
73-
if (waitBarrier.await(TIMEOUT_THRESHOLD, TimeUnit.MILLISECONDS)) {
74-
if (dbusSendExists.exitValue() == 0 && fileManager1Exists.exitValue() == 0) {
75-
return parseOutputForFileManagerInterface(fileManager1Exists);
76-
}
63+
var fileManager1Exists = createFileManager1Check().start();
64+
if (fileManager1Exists.waitFor(TIMEOUT_THRESHOLD, TimeUnit.MILLISECONDS) && fileManager1Exists.exitValue() == 0) {
65+
return parseOutputForFileManagerInterface(fileManager1Exists);
7766
}
7867
} catch (IOException | InterruptedException e) {
7968
//NO-OP
@@ -90,7 +79,7 @@ public boolean isSupported() {
9079
* @throws IOException if the Inputer reader on the process output cannot be created
9180
*/
9281
private boolean parseOutputForFileManagerInterface(Process fileManager1Process) throws IOException {
93-
if( fileManager1Process.isAlive()) {
82+
if (fileManager1Process.isAlive()) {
9483
throw new IllegalArgumentException("Process " + fileManager1Process + " must be terminated to read output.");
9584
}
9685
try (var reader = fileManager1Process.inputReader(StandardCharsets.UTF_8)) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.cryptomator.linux.util;
2+
3+
import java.io.IOException;
4+
import java.util.Objects;
5+
import java.util.concurrent.TimeUnit;
6+
7+
public class SupportUtil {
8+
9+
public static boolean commandExists(String commandName) {
10+
var shell = Objects.requireNonNullElse(System.getenv("SHELL"),"sh");
11+
try {
12+
var cmdExistsProcess = new ProcessBuilder().command(shell, "-c", "command -v " + commandName).start();
13+
if (cmdExistsProcess.waitFor(5000, TimeUnit.MILLISECONDS)) {
14+
return cmdExistsProcess.exitValue() == 0;
15+
}
16+
} catch (IOException | InterruptedException e) {
17+
//NO-OP
18+
}
19+
return false;
20+
}
21+
}

0 commit comments

Comments
 (0)