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

View File

@ -377,35 +377,41 @@ public void deleteMeta(String mapId, String name) throws IOException {
@Override
public void purgeMap(String mapId, Function<ProgressInfo, Boolean> onProgress) throws IOException {
try {
recoveringConnection(connection -> {
executeUpdate(connection,
"DELETE t " +
"FROM `bluemap_map_tile` t " +
" INNER JOIN `bluemap_map` m " +
" ON t.`map` = m.`id` " +
"WHERE m.`map_id` = ?",
mapId
);
synchronized (mapFKs) {
try {
recoveringConnection(connection -> {
executeUpdate(connection,
"DELETE t " +
"FROM `bluemap_map_tile` t " +
" INNER JOIN `bluemap_map` m " +
" ON t.`map` = m.`id` " +
"WHERE m.`map_id` = ?",
mapId
);
executeUpdate(connection,
"DELETE t " +
"FROM `bluemap_map_meta` t " +
" INNER JOIN `bluemap_map` m " +
" ON t.`map` = m.`id` " +
"WHERE m.`map_id` = ?",
mapId
);
executeUpdate(connection,
"DELETE t " +
"FROM `bluemap_map_meta` t " +
" INNER JOIN `bluemap_map` m " +
" ON t.`map` = m.`id` " +
"WHERE m.`map_id` = ?",
mapId
);
executeUpdate(connection,
"DELETE " +
"FROM `bluemap_map` " +
"WHERE `map_id` = ?",
mapId
);
}, 2);
} catch (SQLException ex) {
throw new IOException(ex);
executeUpdate(connection,
"DELETE " +
"FROM `bluemap_map` " +
"WHERE `map_id` = ?",
mapId
);
}, 2);
mapFKs.invalidate(mapId);
} catch (SQLException ex) {
throw new IOException(ex);
}
}
}
@ -670,7 +676,9 @@ private int getMapTileCompressionFK(Compression compression) throws SQLException
}
private int loadMapFK(String mapId) throws SQLException, IOException {
return lookupFK("bluemap_map", "id", "map_id", mapId);
synchronized (mapFKs) {
return lookupFK("bluemap_map", "id", "map_id", mapId);
}
}
private int loadMapTileCompressionFK(Compression compression) throws SQLException, IOException {