Skip to content

Commit 4326850

Browse files
committed
block and wait for answer in dbus-send cmd (with timeout)
1 parent 911f5cd commit 4326850

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ public class DBusFileMangerRevealPath implements RevealPathService {
1818

1919
private static final String FOR_FOLDERS = "org.freedesktop.FileManager1.ShowFolders";
2020
private static final String FOR_FILES = "org.freedesktop.FileManager1.ShowItems";
21+
private static final int TIMEOUT_THRESHOLD=5000;
2122

2223
@Override
2324
public void reveal(Path path) throws RevealFailedException {
2425
try {
2526
var attrs = Files.readAttributes(path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
2627
var uriPath = Arrays.stream(path.toUri().getPath().split("/")).map(s -> URLEncoder.encode(s, StandardCharsets.UTF_8).replace("+", "%20")).collect(Collectors.joining("/"));
2728
ProcessBuilder pb = new ProcessBuilder().command("dbus-send",
29+
"--print-reply",
30+
"--reply-timeout="+TIMEOUT_THRESHOLD,
2831
"--dest=org.freedesktop.FileManager1",
2932
"--type=method_call",
3033
"/org/freedesktop/FileManager1",
@@ -33,7 +36,7 @@ public void reveal(Path path) throws RevealFailedException {
3336
"string:\"\""
3437
);
3538
var process = pb.start();
36-
if (process.waitFor(5000, TimeUnit.MILLISECONDS)) {
39+
if (process.waitFor(TIMEOUT_THRESHOLD, TimeUnit.MILLISECONDS)) {
3740
int exitValue = process.exitValue();
3841
if (exitValue != 0) {
3942
throw new RevealFailedException("dbus-send returned with code" + exitValue);

0 commit comments

Comments
 (0)