fix: prefer .img/.iso/.bin over .ccd/.cue descriptors
Build & Deploy / build-and-deploy (push) Successful in 37s
Build & Deploy / build-and-deploy (push) Successful in 37s
CloneCD (.ccd) and cue sheets (.cue) contain internal FILE references that may not match the actual filename on disk (case mismatch). When a data format (.img, .iso, .bin) exists in the same directory, it's mounted directly instead of the descriptor.
This commit is contained in:
@@ -237,7 +237,7 @@ public class GameService {
|
|||||||
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.
|
// Deduplicate by parent directory — prefer data formats over descriptors.
|
||||||
Set<String> seenDirs = new java.util.HashSet<>();
|
Set<String> seenDirs = new java.util.HashSet<>();
|
||||||
char driveLetter = 'D';
|
char driveLetter = 'D';
|
||||||
for (String img : cdImages) {
|
for (String img : cdImages) {
|
||||||
@@ -245,6 +245,17 @@ public class GameService {
|
|||||||
String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : "";
|
String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : "";
|
||||||
if (!seenDirs.add(parentDir)) continue;
|
if (!seenDirs.add(parentDir)) continue;
|
||||||
String imgLower = img.toLowerCase();
|
String imgLower = img.toLowerCase();
|
||||||
|
// Skip descriptor formats if a data format exists in the same directory
|
||||||
|
if (imgLower.endsWith(".cue") || imgLower.endsWith(".ccd")) {
|
||||||
|
boolean hasData = cdImages.stream().anyMatch(i -> {
|
||||||
|
int is = i.lastIndexOf('/');
|
||||||
|
String ip = is >= 0 ? i.substring(0, is) : "";
|
||||||
|
String il = i.toLowerCase();
|
||||||
|
return ip.equals(parentDir)
|
||||||
|
&& (il.endsWith(".img") || il.endsWith(".iso") || il.endsWith(".bin"));
|
||||||
|
});
|
||||||
|
if (hasData) continue;
|
||||||
|
}
|
||||||
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");
|
||||||
driveLetter++;
|
driveLetter++;
|
||||||
|
|||||||
@@ -580,6 +580,17 @@ public class UploadResource {
|
|||||||
String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : "";
|
String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : "";
|
||||||
if (!seenDirs.add(parentDir)) continue;
|
if (!seenDirs.add(parentDir)) continue;
|
||||||
String imgLower = img.toLowerCase();
|
String imgLower = img.toLowerCase();
|
||||||
|
// Skip descriptor formats if a data format exists in the same directory
|
||||||
|
if (imgLower.endsWith(".cue") || imgLower.endsWith(".ccd")) {
|
||||||
|
boolean hasData = cdImages.stream().anyMatch(i -> {
|
||||||
|
int is = i.lastIndexOf('/');
|
||||||
|
String ip = is >= 0 ? i.substring(0, is) : "";
|
||||||
|
String il = i.toLowerCase();
|
||||||
|
return ip.equals(parentDir)
|
||||||
|
&& (il.endsWith(".img") || il.endsWith(".iso") || il.endsWith(".bin"));
|
||||||
|
});
|
||||||
|
if (hasData) continue;
|
||||||
|
}
|
||||||
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");
|
||||||
driveLetter++;
|
driveLetter++;
|
||||||
@@ -638,9 +649,8 @@ public class UploadResource {
|
|||||||
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
|
// Deduplicate by parent directory — prefer data formats (.img, .iso, .bin)
|
||||||
// .bin files sort first alphabetically and avoid .cue FILE path
|
// over descriptor formats (.cue, .ccd) which can have FILE path case-mismatch.
|
||||||
// case-mismatch issues.
|
|
||||||
Set<String> seenDirs = new java.util.HashSet<>();
|
Set<String> seenDirs = new java.util.HashSet<>();
|
||||||
char driveLetter = 'D';
|
char driveLetter = 'D';
|
||||||
for (String img : cdImages) {
|
for (String img : cdImages) {
|
||||||
@@ -648,6 +658,17 @@ public class UploadResource {
|
|||||||
String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : "";
|
String parentDir = slashIdx >= 0 ? img.substring(0, slashIdx) : "";
|
||||||
if (!seenDirs.add(parentDir)) continue; // already mounted from this dir
|
if (!seenDirs.add(parentDir)) continue; // already mounted from this dir
|
||||||
String imgLower = img.toLowerCase();
|
String imgLower = img.toLowerCase();
|
||||||
|
// Skip descriptor formats if a data format exists in the same directory
|
||||||
|
if (imgLower.endsWith(".cue") || imgLower.endsWith(".ccd")) {
|
||||||
|
boolean hasData = cdImages.stream().anyMatch(i -> {
|
||||||
|
int is = i.lastIndexOf('/');
|
||||||
|
String ip = is >= 0 ? i.substring(0, is) : "";
|
||||||
|
String il = i.toLowerCase();
|
||||||
|
return ip.equals(parentDir)
|
||||||
|
&& (il.endsWith(".img") || il.endsWith(".iso") || il.endsWith(".bin"));
|
||||||
|
});
|
||||||
|
if (hasData) continue; // data file will be mounted instead (lower in list)
|
||||||
|
}
|
||||||
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");
|
||||||
driveLetter++;
|
driveLetter++;
|
||||||
|
|||||||
Reference in New Issue
Block a user