fix client being fucked for new installs

This commit is contained in:
ThatGamerBlue
2021-06-16 19:09:33 +01:00
parent f36a59e48e
commit 8afc700f5f

View File

@@ -33,6 +33,7 @@ import com.openosrs.client.OpenOSRS;
import java.applet.Applet; import java.applet.Applet;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@@ -514,17 +515,21 @@ public class ClientLoader implements Supplier<Applet>
cachedHash = com.google.common.io.Files.asByteSource(cachedInjected).hash(Hashing.sha256()).toString(); cachedHash = com.google.common.io.Files.asByteSource(cachedInjected).hash(Hashing.sha256()).toString();
} }
catch (IOException ex) catch (IOException ex)
{
if (!(ex instanceof FileNotFoundException))
{ {
log.error("Failed to calculate hash for cached file, falling back to vanilla", ex); log.error("Failed to calculate hash for cached file, falling back to vanilla", ex);
updateCheckMode = VANILLA; updateCheckMode = VANILLA;
return; return;
} }
}
byte[] currentInjected = ByteStreams.toByteArray(ClientLoader.class.getResourceAsStream(INJECTED_CLIENT_NAME)); byte[] currentInjected = ByteStreams.toByteArray(ClientLoader.class.getResourceAsStream(INJECTED_CLIENT_NAME));
String currentHash = Hashing.sha256().hashBytes(currentInjected).toString(); String currentHash = Hashing.sha256().hashBytes(currentInjected).toString();
if (!cachedInjected.exists() || !currentHash.equals(cachedHash)) if (!cachedInjected.exists() || !currentHash.equals(cachedHash))
{ {
cachedInjected.getParentFile().mkdirs();
Files.write(cachedInjected.toPath(), currentInjected); Files.write(cachedInjected.toPath(), currentInjected);
} }
} }