From ab1ba503ffdc00eb21a0cdd3a7e51998105b836b Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Fri, 29 May 2026 23:07:07 +0200 Subject: [PATCH] feat: store .jsdos bundle inside game directory instead of as flat file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: data/games/{id}.jsdos (flat, alongside the game dir) After: data/games/{id}/{id}.jsdos (inside the game directory) Benefits: - Delete is atomic — removing the game dir removes everything - Cleaner data directory structure - No orphan .jsdos files on delete Also updated frontend bundleUrl() to use game.bundle_file from the backend, making it path-agnostic. Old flat layout is still served via StaticResource for backward compat. --- frontend/src/lib/api.js | 4 +++- src/main/java/com/dostalgia/GameService.java | 3 +-- src/main/java/com/dostalgia/UploadResource.java | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/api.js b/frontend/src/lib/api.js index 2cb803f..447b596 100644 --- a/frontend/src/lib/api.js +++ b/frontend/src/lib/api.js @@ -106,7 +106,9 @@ export function artworkUrl(path) { /** Get game bundle URL for normal play */ export function bundleUrl(game) { if (!game) return null; - return `/games/${game.id}.jsdos`; + // Use the bundle_file path from the backend (handles both old flat layout + // and new in-directory layout transparently) + return `/games/${game.bundle_file}`; } /** Get game bundle URL for setup mode (runs SETUP.EXE instead) */ diff --git a/src/main/java/com/dostalgia/GameService.java b/src/main/java/com/dostalgia/GameService.java index da78a70..5a31600 100644 --- a/src/main/java/com/dostalgia/GameService.java +++ b/src/main/java/com/dostalgia/GameService.java @@ -127,9 +127,8 @@ public class GameService { } }); } - // Remove flat .jsdos bundle + // Clean up old flat .jsdos locations (pre-game-dir layout — backward compat) Files.deleteIfExists(gamesDir.resolve(id + ".jsdos")); - // Remove flat setup .jsdos bundle (if any) Files.deleteIfExists(gamesDir.resolve(id + ".setup.jsdos")); return true; } diff --git a/src/main/java/com/dostalgia/UploadResource.java b/src/main/java/com/dostalgia/UploadResource.java index e498faf..6660f4c 100644 --- a/src/main/java/com/dostalgia/UploadResource.java +++ b/src/main/java/com/dostalgia/UploadResource.java @@ -95,9 +95,9 @@ public class UploadResource { Path gameDir = svc.gameDir(gameId); Files.createDirectories(gameDir); - // Create .jsdos bundle (ZIP with game files + .jsdos/ config) - String bundleFile = gameId + ".jsdos"; - Path bundlePath = svc.getGamesDir().resolve(bundleFile); + // Create .jsdos bundle inside the game directory + String bundleFile = gameId + "/" + gameId + ".jsdos"; + Path bundlePath = gameDir.resolve(gameId + ".jsdos"); createBundle(extractDir, mainExe, bundlePath); // Detect platform (DOS vs Windows) by reading the main EXE header