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,10 +77,13 @@ public class GameService implements GameStore {
|
||||
);
|
||||
// Detect bundle size
|
||||
try {
|
||||
Path bundlePath = gamesDir.resolve(game.getBundleFile());
|
||||
String bf = game.getBundleFile();
|
||||
if (bf != null) {
|
||||
Path bundlePath = gamesDir.resolve(bf);
|
||||
if (Files.exists(bundlePath)) {
|
||||
game.setBundleSize(Files.size(bundlePath));
|
||||
}
|
||||
}
|
||||
} catch (IOException ignored) {}
|
||||
return game;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ class ZipServiceTest {
|
||||
|
||||
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.size(bundlePath) > 0);
|
||||
@@ -193,7 +193,7 @@ class ZipServiceTest {
|
||||
|
||||
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))) {
|
||||
ZipEntry entry;
|
||||
|
||||
Reference in New Issue
Block a user