fix: GameService.load() NPE on null bundleFile + ZipService test path
Build & Deploy / build-and-deploy (push) Successful in 48s
Build & Deploy / build-and-deploy (push) Successful in 48s
- GameService.load(): null-check bundleFile before resolving path (Path.resolve(null) throws NullPointerException) - ZipServiceTest: pass absolute exePath to createBundle (relativize requires both paths to be absolute or both relative)
This commit is contained in:
@@ -77,9 +77,12 @@ public class GameService implements GameStore {
|
|||||||
);
|
);
|
||||||
// Detect bundle size
|
// Detect bundle size
|
||||||
try {
|
try {
|
||||||
Path bundlePath = gamesDir.resolve(game.getBundleFile());
|
String bf = game.getBundleFile();
|
||||||
if (Files.exists(bundlePath)) {
|
if (bf != null) {
|
||||||
game.setBundleSize(Files.size(bundlePath));
|
Path bundlePath = gamesDir.resolve(bf);
|
||||||
|
if (Files.exists(bundlePath)) {
|
||||||
|
game.setBundleSize(Files.size(bundlePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
return game;
|
return game;
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class ZipServiceTest {
|
|||||||
|
|
||||||
Path bundlePath = dir.resolve("output.jsdos");
|
Path bundlePath = dir.resolve("output.jsdos");
|
||||||
|
|
||||||
zip.createBundle(extractDir, "game.exe", List.of(), bundlePath);
|
zip.createBundle(extractDir, extractDir.resolve("game.exe").toString(), List.of(), bundlePath);
|
||||||
|
|
||||||
assertTrue(Files.exists(bundlePath));
|
assertTrue(Files.exists(bundlePath));
|
||||||
assertTrue(Files.size(bundlePath) > 0);
|
assertTrue(Files.size(bundlePath) > 0);
|
||||||
@@ -193,7 +193,7 @@ class ZipServiceTest {
|
|||||||
|
|
||||||
Path bundlePath = dir.resolve("output.jsdos");
|
Path bundlePath = dir.resolve("output.jsdos");
|
||||||
|
|
||||||
zip.createBundle(extractDir, "game.exe", List.of(), bundlePath);
|
zip.createBundle(extractDir, extractDir.resolve("game.exe").toString(), List.of(), bundlePath);
|
||||||
|
|
||||||
try (ZipInputStream zis = new ZipInputStream(Files.newInputStream(bundlePath))) {
|
try (ZipInputStream zis = new ZipInputStream(Files.newInputStream(bundlePath))) {
|
||||||
ZipEntry entry;
|
ZipEntry entry;
|
||||||
|
|||||||
Reference in New Issue
Block a user