|
11 | 11 | import java.nio.file.Path;
|
12 | 12 | import java.nio.file.attribute.BasicFileAttributes;
|
13 | 13 | import java.util.Arrays;
|
| 14 | +import java.util.concurrent.CountDownLatch; |
14 | 15 | import java.util.concurrent.TimeUnit;
|
15 | 16 | import java.util.stream.Collectors;
|
16 | 17 |
|
@@ -52,14 +53,18 @@ public void reveal(Path path) throws RevealFailedException {
|
52 | 53 |
|
53 | 54 | @Override
|
54 | 55 | public boolean isSupported() {
|
| 56 | + CountDownLatch waitBarrier = new CountDownLatch(3); |
55 | 57 | ProcessBuilder builderExistsDbusSend = new ProcessBuilder().command("which", "dbus-send");
|
56 | 58 | ProcessBuilder builderExistsNautilus = new ProcessBuilder().command("which", "nautilus");
|
57 | 59 | ProcessBuilder builderExistsDolphin = new ProcessBuilder().command("which", "dolphin");
|
58 | 60 | try {
|
59 | 61 | var existsDbusSend = builderExistsDbusSend.start();
|
| 62 | + existsDbusSend.onExit().thenRun(waitBarrier::countDown); |
60 | 63 | var existsNautilus = builderExistsNautilus.start();
|
| 64 | + existsNautilus.onExit().thenRun(waitBarrier::countDown); |
61 | 65 | var existsDolphin = builderExistsDolphin.start();
|
62 |
| - if (existsDbusSend.waitFor(TIMEOUT_THRESHOLD, TimeUnit.MILLISECONDS) && !existsDolphin.isAlive() && !existsNautilus.isAlive()) { |
| 66 | + existsDolphin.onExit().thenRun(waitBarrier::countDown); |
| 67 | + if (waitBarrier.await(TIMEOUT_THRESHOLD, TimeUnit.MILLISECONDS)) { |
63 | 68 | return existsDbusSend.exitValue() == 0 && (existsNautilus.exitValue() == 0 | existsDolphin.exitValue() == 0);
|
64 | 69 | }
|
65 | 70 | } catch (IOException | InterruptedException e) {
|
|
0 commit comments