[FIX] Double read textures

This commit is contained in:
Gravita 2023-04-27 21:12:21 +07:00
parent 5aa4fe8d47
commit 5436b2a2d6

View file

@ -37,16 +37,20 @@ public Texture(String url, boolean cloak, Map<String, String> 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<String, String> 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;
}