Fix Play button 404: bundle path and field name

- .jsdos bundles saved flat in data/games/ so /games/{id}.jsdos serves them
- bundleUrl() uses game.id (matches JSON) instead of game.slug (undefined)
- Delete handler also removes flat .jsdos bundle on game deletion
This commit is contained in:
David Alvarez
2026-05-23 18:38:53 +02:00
parent df5ce4f127
commit 545e2d2bb5
4 changed files with 9 additions and 9 deletions
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -75,7 +75,7 @@ export function artworkUrl(path) {
export function bundleUrl(game) { export function bundleUrl(game) {
if (!game) return null; if (!game) return null;
if (game.bundle_type === "sockdrive") { if (game.bundle_type === "sockdrive") {
return `/api/sockdrive/${game.slug}/file?path=.jsdos/dosbox.conf`; return `/api/sockdrive/${game.id}/file?path=.jsdos/dosbox.conf`;
} }
return `/games/${game.slug}.jsdos`; return `/games/${game.id}.jsdos`;
} }
+5 -5
View File
@@ -187,11 +187,11 @@ func handleGameByID(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Game not found", http.StatusNotFound) http.Error(w, "Game not found", http.StatusNotFound)
return return
} }
// Remove the entire game directory // Remove the game directory (game.json, cover, sockdrive files)
if err := os.RemoveAll(gameDir(g.ID)); err != nil { os.RemoveAll(gameDir(g.ID))
http.Error(w, "Failed to delete game", http.StatusInternalServerError) // Also remove the flat .jsdos bundle if it exists
return bundlePath := filepath.Join(dataDir, "games", g.ID+".jsdos")
} os.Remove(bundlePath)
writeJSON(w, http.StatusOK, map[string]string{"status": "deleted"}) writeJSON(w, http.StatusOK, map[string]string{"status": "deleted"})
default: default:
+2 -2
View File
@@ -126,9 +126,9 @@ func handleUploadGame(w http.ResponseWriter, r *http.Request) {
[]byte(fmt.Sprintf(dosboxConfTemplate, relExe)), 0644) []byte(fmt.Sprintf(dosboxConfTemplate, relExe)), 0644)
bundleFile = ".jsdos/dosbox.conf" bundleFile = ".jsdos/dosbox.conf"
} else { } else {
// Create .jsdos ZIP bundle // Create .jsdos ZIP bundle flat in data/games/
bundleFile = gameID + ".jsdos" bundleFile = gameID + ".jsdos"
bundlePath := filepath.Join(gameDirPath, bundleFile) bundlePath := filepath.Join(filepath.Dir(gameDirPath), bundleFile)
if err := createJSDOSBundle(extractDir, mainExe, bundlePath); err != nil { if err := createJSDOSBundle(extractDir, mainExe, bundlePath); err != nil {
http.Error(w, "Failed to create bundle: "+err.Error(), http.StatusInternalServerError) http.Error(w, "Failed to create bundle: "+err.Error(), http.StatusInternalServerError)
return return