Small application detection fixes

This commit is contained in:
crschnick
2025-05-06 06:18:11 +00:00
parent b9b612731b
commit 72e793e0a9
2 changed files with 16 additions and 2 deletions
@@ -53,6 +53,20 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue {
}
public Optional<Path> findApp() throws Exception {
// Perform a quick check because mdfind is slow
var applicationsDef = Path.of("/Applications/" + applicationName + ".app");
if (Files.exists(applicationsDef)) {
return Optional.of(applicationsDef);
}
var systemApplicationsDef = Path.of("/System/Applications/" + applicationName + ".app");
if (Files.exists(systemApplicationsDef)) {
return Optional.of(systemApplicationsDef);
}
var userApplicationsDef = Path.of(System.getProperty("user.home") + "/Applications/" + applicationName + ".app");
if (Files.exists(userApplicationsDef)) {
return Optional.of(userApplicationsDef);
}
try (ShellControl pc = LocalShell.getShell().start()) {
var out = pc.command(String.format(
"mdfind -literal 'kMDItemFSName = \"%s.app\"' -onlyin /Applications -onlyin ~/Applications -onlyin /System/Applications",
@@ -253,8 +253,8 @@ public interface ExternalRdpClientType extends PrefsChoiceValue {
if (location.isEmpty()) {
location = determineInstallation();
if (location.isEmpty()) {
throw new IOException("Unable to find installation of "
+ toTranslatedString().getValue());
throw ErrorEvent.expected(new IOException("Unable to find installation of "
+ toTranslatedString().getValue()));
}
}