|
54 | 54 | import java.security.MessageDigest; |
55 | 55 | import java.security.NoSuchAlgorithmException; |
56 | 56 | import java.util.Arrays; |
| 57 | +import java.util.zip.ZipException; |
57 | 58 |
|
58 | 59 | @Getter |
59 | 60 | @RequiredArgsConstructor(access = AccessLevel.PRIVATE) |
@@ -121,14 +122,21 @@ public static MinecraftVersion load(@Nullable String id, Path dataRoot, boolean |
121 | 122 | if (!Files.exists(resourcePack)) throw new IOException("Resource-File missing: " + resourcePack); |
122 | 123 | if (!Files.exists(dataPack)) throw new IOException("Resource-File missing: " + dataPack); |
123 | 124 |
|
124 | | - VersionInfo resourcePackVersionInfo = loadVersionInfo(resourcePack); |
125 | | - VersionInfo dataPackVersionInfo = resourcePack.equals(dataPack) ? resourcePackVersionInfo : loadVersionInfo(dataPack); |
| 125 | + try { |
| 126 | + VersionInfo resourcePackVersionInfo = loadVersionInfo(resourcePack); |
| 127 | + VersionInfo dataPackVersionInfo = resourcePack.equals(dataPack) ? resourcePackVersionInfo : loadVersionInfo(dataPack); |
126 | 128 |
|
127 | | - return new MinecraftVersion( |
128 | | - id, |
129 | | - resourcePack, resourcePackVersionInfo.getPackVersion().getResource(), |
130 | | - dataPack, dataPackVersionInfo.getPackVersion().getData() |
131 | | - ); |
| 129 | + return new MinecraftVersion( |
| 130 | + id, |
| 131 | + resourcePack, resourcePackVersionInfo.getPackVersion().getResource(), |
| 132 | + dataPack, dataPackVersionInfo.getPackVersion().getData() |
| 133 | + ); |
| 134 | + } catch (IOException ex) { |
| 135 | + // If something went wrong with reading the resource-files, delete them so they will be re-downloaded on the next try. |
| 136 | + Files.deleteIfExists(resourcePack); |
| 137 | + Files.deleteIfExists(dataPack); |
| 138 | + throw ex; |
| 139 | + } |
132 | 140 |
|
133 | 141 | } |
134 | 142 |
|
|
0 commit comments