From 5db05d8bc75a38f2bcf1b2ee0b1f547a1f0d6d1d Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Wed, 11 Feb 2026 14:33:01 +0100 Subject: [PATCH] Apply suggestions from codereview --- dist/win/resources/main.wxs | 13 +++---------- .../launcher/AdminPropertiesSetter.java | 14 ++++++++------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/dist/win/resources/main.wxs b/dist/win/resources/main.wxs index 9cd56f746..ac5e6a3d1 100644 --- a/dist/win/resources/main.wxs +++ b/dist/win/resources/main.wxs @@ -103,16 +103,9 @@ - - - + + + diff --git a/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java b/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java index 693ea402e..127d5b263 100644 --- a/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java +++ b/src/main/java/org/cryptomator/launcher/AdminPropertiesSetter.java @@ -3,10 +3,13 @@ package org.cryptomator.launcher; import org.slf4j.Logger; import java.io.IOException; +import java.io.Reader; +import java.nio.channels.Channels; +import java.nio.channels.FileChannel; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; +import java.nio.file.StandardOpenOption; import java.util.Properties; import java.util.Set; @@ -72,13 +75,12 @@ class AdminPropertiesSetter { //visible for testing static Properties loadAdminProperties(Path adminPropertiesPath) { var adminProps = new Properties(); - try { - if (Files.size(adminPropertiesPath) > MAX_CONFIG_SIZE_BYTES) { + try (FileChannel ch = FileChannel.open(adminPropertiesPath, StandardOpenOption.READ); // + Reader reader = Channels.newReader(ch, StandardCharsets.UTF_8)) { + if (ch.size() > MAX_CONFIG_SIZE_BYTES) { throw new IOException("Config file %s exceeds maximum size of %d".formatted(adminPropertiesPath, MAX_CONFIG_SIZE_BYTES)); } - try (var reader = Files.newBufferedReader(adminPropertiesPath, StandardCharsets.UTF_8)) { - adminProps.load(reader); - } + adminProps.load(reader); } catch (NoSuchFileException _) { //NO-OP LOG.debug("No admin properties found at {}.", adminPropertiesPath);