From 4739da618d203e7487d5355f1355b2414fd17665 Mon Sep 17 00:00:00 2001 From: aschmitz <29508+aschmitz@users.noreply.github.com> Date: Sat, 30 Sep 2023 22:30:21 -0500 Subject: [PATCH 1/2] 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. --- loader.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/loader.js b/loader.js index 6789a21c..7676a8fd 100644 --- a/loader.js +++ b/loader.js @@ -388,7 +388,8 @@ var Module = null; function get_mame_files(cfgr, metadata, modulecfg, filelist) { var files = [], - bios_files = modulecfg['bios_filenames']; + bios_files = modulecfg['bios_filenames'], + already_fetched_urls = []; bios_files.forEach(function (fname, i) { if (fname) { var title = "Bios File ("+ (i+1) +" of "+ bios_files.length +")"; @@ -421,6 +422,7 @@ var Module = null; : get_zip_url(filename, get_item_name(game)); files.push(cfgr.mountFile('/'+ filename, cfgr.fetchFile(title, url))); + already_fetched_urls.push(url); }); // add on game drive (.chd) files, if any @@ -431,8 +433,10 @@ var Module = null; var title = "Game Drive ("+ (i+1) +" of "+ len +")"; var url = (file.name.includes("/")) ? get_zip_url(file.name) : get_zip_url(file.name, get_item_name(game)); - files.push(cfgr.mountFile(modulecfg.driver + '/' + file.name, - cfgr.fetchFile(title, url))); + if (!already_fetched_urls.includes(url)) { + files.push(cfgr.mountFile(modulecfg.driver + '/' + file.name, + cfgr.fetchFile(title, url))); + } }); Object.keys(peripherals).forEach(function (periph) { From bfc5402e6edc68644d3eee126c5354d2ab2f7289 Mon Sep 17 00:00:00 2001 From: aschmitz <29508+aschmitz@users.noreply.github.com> Date: Sun, 1 Oct 2023 01:15:37 -0500 Subject: [PATCH 2/2] fix: avoid double-fetching BIOS files --- loader.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/loader.js b/loader.js index 7676a8fd..fb5d55df 100644 --- a/loader.js +++ b/loader.js @@ -393,9 +393,10 @@ var Module = null; bios_files.forEach(function (fname, i) { if (fname) { var title = "Bios File ("+ (i+1) +" of "+ bios_files.length +")"; + var url = get_bios_url(fname); files.push(cfgr.mountFile('/'+ fname, - cfgr.fetchFile(title, - get_bios_url(fname)))); + cfgr.fetchFile(title, url))); + already_fetched_urls.push(url); } });