mirror of
https://github.com/rommapp/romm.git
synced 2026-10-12 02:21:58 +00:00
Merge pull request #4848 from rommapp/fix/player-default-descriptor-file
fix(player): boot cue/gdi/ccd/mds disc sets whole by default
This commit is contained in:
@@ -92,6 +92,32 @@ describe("defaultDisc", () => {
|
||||
).toBe(ALL_DISCS);
|
||||
});
|
||||
|
||||
it.each(["cue", "gdi", "ccd", "mds", "CUE"])(
|
||||
"boots every file together when the set has a .%s sheet",
|
||||
(extension) => {
|
||||
expect(
|
||||
defaultDisc([
|
||||
file(1, `Game.${extension}`),
|
||||
file(2, "Game (Track 1).bin"),
|
||||
file(3, "Game (Track 2).bin"),
|
||||
]),
|
||||
).toBe(ALL_DISCS);
|
||||
},
|
||||
);
|
||||
|
||||
it("boots a lone sheet when it is the rom's only file", () => {
|
||||
expect(defaultDisc([file(1, "Game.cue")])).toBe(1);
|
||||
});
|
||||
|
||||
it("keeps a remembered track over the sheet default", () => {
|
||||
const cueSet = [file(1, "Game.cue"), file(2, "Game.iso")];
|
||||
expect(resolveStoredDisc("2", cueSet)).toEqual({ disc: 2, stale: false });
|
||||
expect(resolveStoredDisc(null, cueSet)).toEqual({
|
||||
disc: ALL_DISCS,
|
||||
stale: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("boots the first file when a multi-file set has no playlist", () => {
|
||||
expect(defaultDisc(files(3, 4))).toBe(3);
|
||||
});
|
||||
|
||||
@@ -87,10 +87,19 @@ export function selectableDiscFiles<T extends DiscFile>(
|
||||
return bootableFiles(files).filter((f) => !isM3uFile(f));
|
||||
}
|
||||
|
||||
// A set shipping its own .m3u is a curated multi-disc release, so boot it whole;
|
||||
// anything else boots one file to avoid pulling hundreds of unused MB.
|
||||
// Sheets that point at sibling track files, so neither the sheet nor a track
|
||||
// boots alone (issue #4209). Kept in step with backend/utils/m3u.py.
|
||||
const DESCRIPTOR_EXTENSIONS: readonly string[] = ["cue", "gdi", "ccd", "mds"];
|
||||
|
||||
function isDescriptorFile(file: DiscFile): boolean {
|
||||
const extension = file.file_name.toLowerCase().split(".").pop() ?? "";
|
||||
return isM3uFile(file) || DESCRIPTOR_EXTENSIONS.includes(extension);
|
||||
}
|
||||
|
||||
// A set carrying a playlist or disc sheet only boots whole; anything else boots
|
||||
// one file to avoid pulling hundreds of unused MB.
|
||||
export function defaultDisc(files: readonly DiscFile[]): DiscSelection {
|
||||
if (files.length > 1 && files.some(isM3uFile)) return ALL_DISCS;
|
||||
if (files.length > 1 && files.some(isDescriptorFile)) return ALL_DISCS;
|
||||
return bootableFiles(files)[0]?.id ?? null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user