Skip to content

Commit 2c0f834

Browse files
committed
add additional sanity condition for isSupported method
1 parent 6ae79bb commit 2c0f834

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ public class FreedesktopAutoStartService implements AutoStartProvider {
3838

3939
private final Path autostartFile;
4040
private final String content;
41+
private final boolean hasExecValue;
4142

4243
public FreedesktopAutoStartService() {
4344
var xdgConfigDirString = Objects.requireNonNullElse(System.getenv("XDG_CONFIG_HOME"), System.getProperty("user.home") + "/.config");
4445
this.autostartFile = Path.of(xdgConfigDirString, "autostart", AUTOSTART_FILENAME);
4546

4647
var execValue = System.getProperty(CMD_PROPERTY);
4748
if (execValue == null) {
48-
LOG.debug("Property {} not set, using command path", CMD_PROPERTY);
49+
LOG.debug("JVM property {} not set, using command path", CMD_PROPERTY);
4950
execValue = ProcessHandle.current().info().command().orElse("");
5051
}
52+
this.hasExecValue = execValue.isBlank();
5153
this.content = CONTENT_TEMPLATE.formatted(execValue, this.getClass().getName());
5254
}
5355

@@ -77,7 +79,7 @@ public synchronized boolean isEnabled() {
7779
@CheckAvailability
7880
public boolean isSupported() {
7981
//TODO: might need to research which Desktop Environments support this
80-
return Files.exists(autostartFile.getParent());
82+
return hasExecValue && Files.exists(autostartFile.getParent());
8183
}
8284

8385
}

0 commit comments

Comments
 (0)