From fc4f18136405b4fd603161c41357e22e7d21a42c Mon Sep 17 00:00:00 2001 From: Max Weber Date: Mon, 3 Jan 2022 17:42:01 -0700 Subject: [PATCH] rl-client: keep plugin hub jars around for longer if you started 2 clients with different configs at the same time one client could delete files out from under the other while it was trying to load them, causing them to fail to load --- .../client/externalplugins/ExternalPluginManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginManager.java b/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginManager.java index 91f13d66f1..d5adf70d08 100644 --- a/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginManager.java @@ -35,6 +35,8 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.URL; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -167,6 +169,9 @@ public class ExternalPluginManager SplashScreen.init(); } + Instant now = Instant.now(); + Instant keepAfter = now.minus(3, ChronoUnit.DAYS); + SplashScreen.stage(splashStart, null, "Downloading external plugins"); Set externalPlugins = new HashSet<>(); @@ -189,6 +194,7 @@ public class ExternalPluginManager { externalPlugins.add(manifest); + manifest.getJarFile().setLastModified(now.toEpochMilli()); if (!manifest.isValid()) { needsDownload.add(manifest); @@ -206,7 +212,7 @@ public class ExternalPluginManager { for (File fi : files) { - if (!keep.contains(fi)) + if (!keep.contains(fi) && fi.lastModified() < keepAfter.toEpochMilli()) { fi.delete(); }