Skip to content

Commit 2fcfb8f

Browse files
committed
If reading existing client-jars fails, delete them
1 parent 79eb243 commit 2fcfb8f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

core/src/main/java/de/bluecolored/bluemap/core/resources/MinecraftVersion.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import java.security.MessageDigest;
5555
import java.security.NoSuchAlgorithmException;
5656
import java.util.Arrays;
57+
import java.util.zip.ZipException;
5758

5859
@Getter
5960
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@@ -121,14 +122,21 @@ public static MinecraftVersion load(@Nullable String id, Path dataRoot, boolean
121122
if (!Files.exists(resourcePack)) throw new IOException("Resource-File missing: " + resourcePack);
122123
if (!Files.exists(dataPack)) throw new IOException("Resource-File missing: " + dataPack);
123124

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);
126128

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+
}
132140

133141
}
134142

0 commit comments

Comments
 (0)