Skip to content

Commit

Permalink
Fix bug that could delete downloadedMaps folder. (#12375)
Browse files Browse the repository at this point in the history
* Fix bug that could delete downloadedMaps folder.

This would happen when removing a map where the content root isn't nested in a sub-dir, example "2020".
Fixes: #12373

* Formatting.
  • Loading branch information
asvitkine authored Feb 29, 2024
1 parent bc4bf6e commit dbee549
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,16 @@ private static String normalizeName(final String mapName) {
* directory of the 'map.yml' file describing that map.
*/
public Optional<Path> findMapFolderByName(final String mapName) {
return findContentRootForMapName(mapName).map(Path::getParent);
return findContentRootForMapName(mapName)
.map(
p -> {
Path parent = p.getParent();
// Some maps have their content root be the map folder itself.
if (parent.equals(ClientFileSystemHelper.getUserMapsFolder())) {
return p;
}
return parent;
});
}

public Optional<Path> findMapSkin(final String mapName, final String skinName) {
Expand Down

0 comments on commit dbee549

Please sign in to comment.