Cache limit

This commit is contained in:
Ethan O'Brien 2023-07-03 11:16:44 -05:00
parent b53577aa30
commit 9a790b70db
2 changed files with 8 additions and 4 deletions

View file

@ -612,10 +612,13 @@ class EmulatorJS {
return; return;
} }
gotGameData(res.data); gotGameData(res.data);
this.storage.rom.put(this.config.gameUrl.split("/").pop(), { const limit = (typeof this.config.cacheLimit === "number") ? this.config.cacheLimit : 1073741824;
"content-length": res.headers['content-length'], if (parseFloat(res.headers['content-length']) < limit) {
data: res.data this.storage.rom.put(this.config.gameUrl.split("/").pop(), {
}) "content-length": res.headers['content-length'],
data: res.data
})
}
}, (progress) => { }, (progress) => {
this.textElem.innerText = this.localization("Download Game Data") + progress; this.textElem.innerText = this.localization("Download Game Data") + progress;
}, true, {responseType: "arraybuffer", method: "GET"}); }, true, {responseType: "arraybuffer", method: "GET"});

View file

@ -58,6 +58,7 @@
config.startOnLoad = window.EJS_startOnLoaded; config.startOnLoad = window.EJS_startOnLoaded;
config.filePaths = window.EJS_paths; config.filePaths = window.EJS_paths;
config.loadState = window.EJS_loadStateURL; config.loadState = window.EJS_loadStateURL;
config.cacheLimit = window.EJS_CacheLimit;
new EmulatorJS(EJS_player, config); new EmulatorJS(EJS_player, config);