Skip to content

Commit

Permalink
fix missing logDir path resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Jun 20, 2023
1 parent ebea8ef commit b3d8df0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/cryptomator/common/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public class Environment {
private static final String PLUGIN_DIR_PROP_NAME = "cryptomator.pluginDir";
private static final String TRAY_ICON_PROP_NAME = "cryptomator.showTrayIcon";

private Environment() {}
private Environment() {
//hack, needed for logging directory to be setup correctly
PropertiesPreprocessor.run();
}

public void log() {
LOG.info("user.home: {}", System.getProperty("user.home"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ static String process(String value) {
return TEMPLATE.matcher(value).replaceAll(match -> //
switch (match.group(1)) {
case "appdir" -> ENV.get("APPDIR");
case "appdata" -> ENV.get("APPDATA");
case "localappdata" -> ENV.get("LOCALAPPDATA");
case "userhome" -> System.getProperty("user.home");
case "appdata" -> ENV.get("APPDATA").replace("\\","\\\\");
case "localappdata" -> ENV.get("LOCALAPPDATA").replace("\\","\\\\");
case "userhome" -> System.getProperty("user.home").replace("\\","\\\\");
default -> {
LOG.warn("Found unknown variable @{{}} in property value {}.", match.group(), value);
yield match.group();
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/org/cryptomator/launcher/Cryptomator.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@Singleton
public class Cryptomator {

private static final Environment ENV = Environment.getInstance();
private static final long STARTUP_TIME = System.currentTimeMillis();
// DaggerCryptomatorComponent gets generated by Dagger.
// Run Maven and include target/generated-sources/annotations in your IDE.
Expand All @@ -37,15 +38,13 @@ public class Cryptomator {

private final DebugMode debugMode;
private final SupportedLanguages supportedLanguages;
private final Environment env;
private final Lazy<IpcMessageHandler> ipcMessageHandler;
private final ShutdownHook shutdownHook;

@Inject
Cryptomator(DebugMode debugMode, SupportedLanguages supportedLanguages, Environment env, Lazy<IpcMessageHandler> ipcMessageHandler, ShutdownHook shutdownHook) {
Cryptomator(DebugMode debugMode, SupportedLanguages supportedLanguages, Lazy<IpcMessageHandler> ipcMessageHandler, ShutdownHook shutdownHook) {
this.debugMode = debugMode;
this.supportedLanguages = supportedLanguages;
this.env = env;
this.ipcMessageHandler = ipcMessageHandler;
this.shutdownHook = shutdownHook;
}
Expand All @@ -64,7 +63,6 @@ public static void main(String[] args) {
System.out.printf("Cryptomator version %s (build %s)%n", appVer, buildNumber);
return;
}
PropertiesPreprocessor.run();
int exitCode = CRYPTOMATOR_COMPONENT.application().run(args);
LOG.info("Exit {}", exitCode);
System.exit(exitCode); // end remaining non-daemon threads.
Expand All @@ -77,17 +75,17 @@ public static void main(String[] args) {
* @return Nonzero exit code in case of an error.
*/
private int run(String[] args) {
env.log();
ENV.log();
LOG.debug("Dagger graph initialized after {}ms", System.currentTimeMillis() - STARTUP_TIME);
LOG.info("Starting Cryptomator {} on {} {} ({})", env.getAppVersion(), SystemUtils.OS_NAME, SystemUtils.OS_VERSION, SystemUtils.OS_ARCH);
LOG.info("Starting Cryptomator {} on {} {} ({})", ENV.getAppVersion(), SystemUtils.OS_NAME, SystemUtils.OS_VERSION, SystemUtils.OS_ARCH);
debugMode.initialize();
supportedLanguages.applyPreferred();

/*
* Attempts to create an IPC connection to a running Cryptomator instance and sends it the given args.
* If no external process could be reached, the args will be handled by the loopback IPC endpoint.
*/
try (var communicator = IpcCommunicator.create(env.ipcSocketPath().toList())) {
try (var communicator = IpcCommunicator.create(ENV.ipcSocketPath().toList())) {
if (communicator.isClient()) {
communicator.sendHandleLaunchargs(List.of(args));
communicator.sendRevealRunningApp();
Expand Down

0 comments on commit b3d8df0

Please sign in to comment.