diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java index d09db69c..238e9de3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java @@ -41,8 +41,7 @@ public void init() { public final boolean sync() throws IOException { boolean exists = exists(); - if (sign != null) - CommonHelper.removeExc(sign); + CommonHelper.removeExc(sign); if (binary != null) { CommonHelper.removeExc(binary.getBytes()); CommonHelper.removeExc(binary.getDigest()); @@ -50,9 +49,11 @@ public final boolean sync() throws IOException { binary = exists ? new DigestBytesHolder(IOHelper.read(syncBinaryFile), SecurityHelper.DigestAlgorithm.SHA512) : null; sign = exists ? SecurityHelper.sign(IOHelper.read(syncBinaryFile), server.privateKey) : null; CommonHelper.addExc(sign); - CommonHelper.addExc(binary.getBytes()); - CommonHelper.addExc(binary.getDigest()); - return exists; + if (binary != null) { + CommonHelper.addExc(binary.getBytes()); + CommonHelper.addExc(binary.getDigest()); + } + return exists; } public static Path resolve(LaunchServer server, String ext) { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index 18e4a1de..b0000ead 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -143,12 +143,14 @@ public static GsonBuilder newBuilder() { } public static void addExc(byte[] exclusion) { + if (exclusion == null) return; JsonArray add = new JsonArray(exclusion.length); for (byte b : exclusion) add.add(new JsonPrimitive(b)); ByteArrayToBase64TypeAdapter.exclusions.put(exclusion, add); } public static void removeExc(byte[] exclusion) { + if (exclusion == null) return; ByteArrayToBase64TypeAdapter.exclusions.remove(exclusion); }