Skip to content

Commit

Permalink
Map zip extraction: smarter precondition (#12769)
Browse files Browse the repository at this point in the history
Multiple bots starting up at the same time can clobber each others
files. This update makes the precondition check during map extraction
smarter, to just no-op if the map-to-extract no longer exists.
  • Loading branch information
DanVanAtta authored Jul 25, 2024
1 parent caad104 commit d9e67ea
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,17 @@ private Collection<Path> findAllZippedMapFiles() {
* @return Returns extracted location (if successful, otherwise empty)
*/
public static Optional<Path> unzipMap(final Path mapZip) {
if (!Files.exists(mapZip)) {
String msg =
"Unexpected, cannot extract map zip, no file exists at: " + mapZip.toAbsolutePath();
if (GameRunner.headless()) {
log.warn(msg);
} else {
log.info(msg);
}
return Optional.empty();
}
Preconditions.checkArgument(!Files.isDirectory(mapZip), mapZip.toAbsolutePath());
Preconditions.checkArgument(Files.exists(mapZip), mapZip.toAbsolutePath());
Preconditions.checkArgument(
mapZip.getFileName().toString().endsWith(".zip"), mapZip.toAbsolutePath());

Expand Down

0 comments on commit d9e67ea

Please sign in to comment.