Also remove the cached FK for the map-id when we delete it from the db >_>

This commit is contained in:
Lukas Rieger (Blue) 2023-03-17 20:29:52 +01:00
parent 1336d26b9f
commit 8af13df3f9
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
1 changed files with 36 additions and 28 deletions

View File

@ -377,6 +377,7 @@ public class SQLStorage extends Storage {
@Override
public void purgeMap(String mapId, Function<ProgressInfo, Boolean> onProgress) throws IOException {
synchronized (mapFKs) {
try {
recoveringConnection(connection -> {
executeUpdate(connection,
@ -397,6 +398,7 @@ public class SQLStorage extends Storage {
mapId
);
executeUpdate(connection,
"DELETE " +
"FROM `bluemap_map` " +
@ -404,10 +406,14 @@ public class SQLStorage extends Storage {
mapId
);
}, 2);
mapFKs.invalidate(mapId);
} catch (SQLException ex) {
throw new IOException(ex);
}
}
}
@Override
public Collection<String> collectMapIds() throws IOException {
@ -670,8 +676,10 @@ public class SQLStorage extends Storage {
}
private int loadMapFK(String mapId) throws SQLException, IOException {
synchronized (mapFKs) {
return lookupFK("bluemap_map", "id", "map_id", mapId);
}
}
private int loadMapTileCompressionFK(Compression compression) throws SQLException, IOException {
return lookupFK("bluemap_map_tile_compression", "id", "compression", compression.getTypeId());