From 89b3e4ca7e34a48457d048299bbc874b8679796d Mon Sep 17 00:00:00 2001 From: Colin S <3526918+cbs228@users.noreply.github.com> Date: Sat, 16 Sep 2023 17:33:04 -0500 Subject: [PATCH] common: don't cleanup icon files on unregister MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In previous versions, icons files were removed from the web directory when they were unregistered via `IconRegistry.unregister()`. Icons are unregistered when plugins are shut down or removed. When an external web server is in use, map tiles remain available to clients after the game server has stopped—but registered icons do not. The removed icons result in ugly "broken link" images on clients. Instead of removing icon files immediately when they are unregistered, defer the removal until squaremap's next startup. Old icon files will be overwritten with new ones if necessary. See also: --- .../java/xyz/jpenilla/squaremap/common/IconRegistry.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/common/src/main/java/xyz/jpenilla/squaremap/common/IconRegistry.java b/common/src/main/java/xyz/jpenilla/squaremap/common/IconRegistry.java index 9a9cbd4c..d867dc5c 100644 --- a/common/src/main/java/xyz/jpenilla/squaremap/common/IconRegistry.java +++ b/common/src/main/java/xyz/jpenilla/squaremap/common/IconRegistry.java @@ -51,11 +51,6 @@ public void unregister(final Key key) { if (removed == null) { throw noImageRegistered(key); } - try { - Files.delete(this.directory.resolve(key.getKey() + ".png")); - } catch (IOException e) { - throw failedToDeleteImage(key, e); - } } @Override @@ -83,10 +78,6 @@ private static IllegalArgumentException failedToCreateRegistry(final IOException return new IllegalArgumentException("Failed to setup icon registry", e); } - private static IllegalArgumentException failedToDeleteImage(final Key key, final IOException e) { - return new IllegalArgumentException(String.format("Failed to delete image for key '%s'", key.getKey()), e); - } - private static IllegalArgumentException failedToWriteImage(final Key key, final IOException e) { return new IllegalArgumentException(String.format("Failed to write image for key '%s'", key.getKey()), e); }