Skip to content

Commit

Permalink
common: don't cleanup icon files on unregister
Browse files Browse the repository at this point in the history
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:

<#114>
  • Loading branch information
cbs228 committed Sep 17, 2023
1 parent b26284a commit 89b3e4c
Showing 1 changed file with 0 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 89b3e4c

Please sign in to comment.