restore dedup: mount one CD image per directory, prefer .bin over .cue
Build & Deploy / build-and-deploy (push) Successful in 37s

Since GameService now preserves CD images when regenerating configs,
the dedup logic is safe to re-add. Deduplicates by parent directory
so a .bin and .cue from the same folder only produce one imgmount.
Alphabetical sort ensures .bin (b) is mounted before .cue (c).
This commit is contained in:
Hermes Agent
2026-06-03 10:22:27 +02:00
parent 7c4d090de0
commit 383c66b166
2 changed files with 14 additions and 2 deletions
+6 -1
View File
@@ -236,9 +236,14 @@ public class GameService {
sb.append("[sblaster]\nsbtype=sb16\nirq=7\ndma=1\nhdma=5\n\n"); sb.append("[sblaster]\nsbtype=sb16\nirq=7\ndma=1\nhdma=5\n\n");
sb.append("[dos]\nxms=true\nems=true\numb=true\n\n"); sb.append("[dos]\nxms=true\nems=true\numb=true\n\n");
sb.append("[autoexec]\n@echo off\nmount c .\n"); sb.append("[autoexec]\n@echo off\nmount c .\n");
// Mount CD images as D:, E:, … so games can find their CD // Mount CD images as D:, E:, … so games can find their CD.
// Deduplicate by parent directory — prefer .bin over .cue.
Set<String> seenDirs = new java.util.HashSet<>();
char driveLetter = 'D'; char driveLetter = 'D';
for (String img : cdImages) { for (String img : cdImages) {
int slashIdx = img.lastIndexOf('/');
String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : "";
if (!seenDirs.add(parentDir)) continue;
String imgLower = img.toLowerCase(); String imgLower = img.toLowerCase();
String flags = imgLower.endsWith(".bin") ? " -t cdrom -fs iso" : " -t cdrom"; String flags = imgLower.endsWith(".bin") ? " -t cdrom -fs iso" : " -t cdrom";
sb.append("imgmount ").append(driveLetter).append(" \"").append(img).append("\"").append(flags).append("\n"); sb.append("imgmount ").append(driveLetter).append(" \"").append(img).append("\"").append(flags).append("\n");
@@ -584,9 +584,16 @@ public class UploadResource {
sb.append("[autoexec]\n"); sb.append("[autoexec]\n");
sb.append("@echo off\n"); sb.append("@echo off\n");
sb.append("mount c .\n"); sb.append("mount c .\n");
// Mount CD images as D:, E:, … so games can find their CD // Mount CD images as D:, E:, … so games can find their CD.
// Deduplicate by parent directory — prefer .bin over .cue since
// .bin files sort first alphabetically and avoid .cue FILE path
// case-mismatch issues.
Set<String> seenDirs = new java.util.HashSet<>();
char driveLetter = 'D'; char driveLetter = 'D';
for (String img : cdImages) { for (String img : cdImages) {
int slashIdx = img.lastIndexOf('/');
String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : "";
if (!seenDirs.add(parentDir)) continue; // already mounted from this dir
String imgLower = img.toLowerCase(); String imgLower = img.toLowerCase();
String flags = imgLower.endsWith(".bin") ? " -t cdrom -fs iso" : " -t cdrom"; String flags = imgLower.endsWith(".bin") ? " -t cdrom -fs iso" : " -t cdrom";
sb.append("imgmount ").append(driveLetter).append(" \"").append(img).append("\"").append(flags).append("\n"); sb.append("imgmount ").append(driveLetter).append(" \"").append(img).append("\"").append(flags).append("\n");