Skip to content

Commit 8af13df

Browse files
committed
Also remove the cached FK for the map-id when we delete it from the db >_>
1 parent 1336d26 commit 8af13df

File tree

1 file changed

+36
-28
lines changed
  • BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql

1 file changed

+36
-28
lines changed

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorage.java

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -377,35 +377,41 @@ public void deleteMeta(String mapId, String name) throws IOException {
377377

378378
@Override
379379
public void purgeMap(String mapId, Function<ProgressInfo, Boolean> onProgress) throws IOException {
380-
try {
381-
recoveringConnection(connection -> {
382-
executeUpdate(connection,
383-
"DELETE t " +
384-
"FROM `bluemap_map_tile` t " +
385-
" INNER JOIN `bluemap_map` m " +
386-
" ON t.`map` = m.`id` " +
387-
"WHERE m.`map_id` = ?",
388-
mapId
389-
);
380+
synchronized (mapFKs) {
381+
try {
382+
recoveringConnection(connection -> {
383+
executeUpdate(connection,
384+
"DELETE t " +
385+
"FROM `bluemap_map_tile` t " +
386+
" INNER JOIN `bluemap_map` m " +
387+
" ON t.`map` = m.`id` " +
388+
"WHERE m.`map_id` = ?",
389+
mapId
390+
);
390391

391-
executeUpdate(connection,
392-
"DELETE t " +
393-
"FROM `bluemap_map_meta` t " +
394-
" INNER JOIN `bluemap_map` m " +
395-
" ON t.`map` = m.`id` " +
396-
"WHERE m.`map_id` = ?",
397-
mapId
398-
);
392+
executeUpdate(connection,
393+
"DELETE t " +
394+
"FROM `bluemap_map_meta` t " +
395+
" INNER JOIN `bluemap_map` m " +
396+
" ON t.`map` = m.`id` " +
397+
"WHERE m.`map_id` = ?",
398+
mapId
399+
);
399400

400-
executeUpdate(connection,
401-
"DELETE " +
402-
"FROM `bluemap_map` " +
403-
"WHERE `map_id` = ?",
404-
mapId
405-
);
406-
}, 2);
407-
} catch (SQLException ex) {
408-
throw new IOException(ex);
401+
402+
executeUpdate(connection,
403+
"DELETE " +
404+
"FROM `bluemap_map` " +
405+
"WHERE `map_id` = ?",
406+
mapId
407+
);
408+
}, 2);
409+
410+
mapFKs.invalidate(mapId);
411+
412+
} catch (SQLException ex) {
413+
throw new IOException(ex);
414+
}
409415
}
410416
}
411417

@@ -670,7 +676,9 @@ private int getMapTileCompressionFK(Compression compression) throws SQLException
670676
}
671677

672678
private int loadMapFK(String mapId) throws SQLException, IOException {
673-
return lookupFK("bluemap_map", "id", "map_id", mapId);
679+
synchronized (mapFKs) {
680+
return lookupFK("bluemap_map", "id", "map_id", mapId);
681+
}
674682
}
675683

676684
private int loadMapTileCompressionFK(Compression compression) throws SQLException, IOException {

0 commit comments

Comments
 (0)