mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-07-31 20:36:03 +00:00
cleanup
This commit is contained in:
@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
@@ -84,4 +85,12 @@ public interface IpcCommunicator extends Closeable {
|
||||
*/
|
||||
@Override
|
||||
void close() throws IOException;
|
||||
|
||||
default void closeUnchecked() throws UncheckedIOException {
|
||||
try {
|
||||
close();
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ class Server implements IpcCommunicator {
|
||||
serverSocketChannel.close();
|
||||
} finally {
|
||||
Files.deleteIfExists(socketPath);
|
||||
LOG.debug("IPC server closed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,14 +83,7 @@ public class Cryptomator {
|
||||
LOG.info("Found running application instance. Shutting down...");
|
||||
return 2;
|
||||
} else {
|
||||
// TODO: move this to a better place?
|
||||
shutdownHook.runOnShutdown(() -> {
|
||||
try {
|
||||
communicator.close();
|
||||
} catch (IOException e) {
|
||||
LOG.warn("IPC cleanup failed");
|
||||
}
|
||||
});
|
||||
shutdownHook.runOnShutdown(communicator::closeUnchecked);
|
||||
var executor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("IPC-%d").build());
|
||||
var msgHandler = ipcMessageHandler.get();
|
||||
msgHandler.handleLaunchArgs(List.of(args));
|
||||
|
||||
Reference in New Issue
Block a user