Skip to content

Commit 4739da6

Browse files
committed
fix: don't double-load files for MAME items
This prevents us from loading a file as both a driver and a game file, preventing double-loading .chd files when `meta.emulator_ext` is `chd`. In these cases, it appears that the files aren't needed as driver files, so we can safely just load them as game files and ignore the duplicates we'd get by loading all .chd files as drivers.
1 parent 6b318f0 commit 4739da6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

loader.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ var Module = null;
388388

389389
function get_mame_files(cfgr, metadata, modulecfg, filelist) {
390390
var files = [],
391-
bios_files = modulecfg['bios_filenames'];
391+
bios_files = modulecfg['bios_filenames'],
392+
already_fetched_urls = [];
392393
bios_files.forEach(function (fname, i) {
393394
if (fname) {
394395
var title = "Bios File ("+ (i+1) +" of "+ bios_files.length +")";
@@ -421,6 +422,7 @@ var Module = null;
421422
: get_zip_url(filename, get_item_name(game));
422423
files.push(cfgr.mountFile('/'+ filename,
423424
cfgr.fetchFile(title, url)));
425+
already_fetched_urls.push(url);
424426
});
425427

426428
// add on game drive (.chd) files, if any
@@ -431,8 +433,10 @@ var Module = null;
431433
var title = "Game Drive ("+ (i+1) +" of "+ len +")";
432434
var url = (file.name.includes("/")) ? get_zip_url(file.name)
433435
: get_zip_url(file.name, get_item_name(game));
434-
files.push(cfgr.mountFile(modulecfg.driver + '/' + file.name,
435-
cfgr.fetchFile(title, url)));
436+
if (!already_fetched_urls.includes(url)) {
437+
files.push(cfgr.mountFile(modulecfg.driver + '/' + file.name,
438+
cfgr.fetchFile(title, url)));
439+
}
436440
});
437441

438442
Object.keys(peripherals).forEach(function (periph) {

0 commit comments

Comments
 (0)