From 5436b2a2d63052c94aa47dc84c4bb2f6d421df80 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Thu, 27 Apr 2023 21:12:21 +0700 Subject: [PATCH] [FIX] Double read textures --- .../main/java/pro/gravit/launcher/profiles/Texture.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/Texture.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/Texture.java index 2b8d26bc..f4a070d9 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/Texture.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/Texture.java @@ -37,16 +37,20 @@ public Texture(String url, boolean cloak, Map metadata) throws I } // Get digest of texture - digest = SecurityHelper.digest(DIGEST_ALGO, new URL(url)); + digest = SecurityHelper.digest(DIGEST_ALGO, texture); this.metadata = metadata; // May be auto-detect? } public Texture(String url, Path local, boolean cloak, Map metadata) throws IOException { this.url = IOHelper.verifyURL(url); + byte[] texture; try (InputStream input = IOHelper.newInput(local)) { + texture = IOHelper.read(input); + } + try (ByteArrayInputStream input = new ByteArrayInputStream(texture)) { IOHelper.readTexture(input, cloak); // Verify texture } - this.digest = SecurityHelper.digest(DIGEST_ALGO, local); + this.digest = SecurityHelper.digest(DIGEST_ALGO, texture); this.metadata = metadata; }