mirror of
https://github.com/siemens-mobile-hacks/pmb887x-emu-web.git
synced 2026-11-25 22:27:22 +00:00
page: worded download errors, honest download progress, a recalc hint
- A preset download that fails at the network level showed fetch's bare "TypeError: Failed to fetch"; it now says which file could not be downloaded from which host and to press Start again. - Download progress added the previous file's content-length when the file changed, not what arrived, and ignored files already cached: a retry that skipped a cached 128 MiB image showed 0 / 128 MiB for the remaining 32 KiB. It now starts from the cached files' sizes and adds each finished file at what it brought. - "Not a recognizable Siemens fullflash layout" now names the way on: "Run as is" under Advanced ▸ Siemens keys, or check the device. - render() asked MediaRecorder.isTypeSupported up to seven times per call; the two answers are asked once. Review: WEB-20. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
82f53c95bd
commit
856ffb4aaa
3 changed files with 25 additions and 8 deletions
16
site/app.js
16
site/app.js
|
|
@ -1717,16 +1717,18 @@ async function boot() {
|
|||
// a 64 MiB fullflash is a long wait — Cancel stops it (the catch
|
||||
// below turns the AbortError into a plain "cancelled")
|
||||
downloadAbort = new AbortController();
|
||||
dlLoaded = 0;
|
||||
dlLoaded = st.totalSize; // the files already cached
|
||||
dlTotal = preset.size;
|
||||
dlWhat = "fullflash";
|
||||
setEmuState("downloading");
|
||||
await refreshPresetUi(); // say so on the preset line before byte one
|
||||
let doneBytes = 0, curFile = null, curTotal = 0;
|
||||
// what is already here counts as done: the cached files, then each
|
||||
// finished file at what it actually brought
|
||||
let doneBytes = st.totalSize, curFile = null, curLoaded = 0;
|
||||
try {
|
||||
fetched = await downloadEntry(preset, (name, loaded, total) => {
|
||||
if (name !== curFile) { doneBytes += curTotal; curFile = name; }
|
||||
curTotal = total;
|
||||
if (name !== curFile) { doneBytes += curLoaded; curFile = name; }
|
||||
curLoaded = loaded;
|
||||
dlLoaded = doneBytes + loaded;
|
||||
dlTotal = preset.size || (doneBytes + total);
|
||||
const pct = dlTotal ? Math.round((dlLoaded / dlTotal) * 100) : null;
|
||||
|
|
@ -2481,8 +2483,10 @@ const REC_AV_TYPES = [
|
|||
// H.264 first: where the browser can record it the file plays anywhere,
|
||||
// and the mp4 container is the one Safari writes. VP9/VP8 webm remain
|
||||
// the fallback, so the extension follows whatever isTypeSupported picks.
|
||||
const recType = (sound = true) => typeof MediaRecorder === "undefined" ? undefined
|
||||
: (sound ? REC_AV_TYPES : REC_TYPES).find((t) => MediaRecorder.isTypeSupported(t));
|
||||
// asked once: the answers cannot change, and render() wants one every time
|
||||
const recTypes = typeof MediaRecorder === "undefined" ? []
|
||||
: [REC_TYPES, REC_AV_TYPES].map((list) => list.find((t) => MediaRecorder.isTypeSupported(t)));
|
||||
const recType = (sound = true) => recTypes[sound ? 1 : 0];
|
||||
const recExt = (t) => t?.startsWith("video/mp4") ? ".mp4" : ".webm";
|
||||
let recorder = null;
|
||||
let recDone = []; // run after the file has been handed over
|
||||
|
|
|
|||
|
|
@ -297,8 +297,20 @@ export async function entryCacheState(entry) {
|
|||
}
|
||||
|
||||
// fetch -> Blob, reporting (file, loadedBytes, totalBytes) while the body
|
||||
// streams in. An aborted signal rejects the pending read with AbortError.
|
||||
// streams in. An aborted signal rejects the pending read with AbortError; a
|
||||
// network failure (fetch's bare "TypeError: Failed to fetch") is said in
|
||||
// words.
|
||||
async function fetchWithProgress(file, onProgress, signal) {
|
||||
try {
|
||||
return await fetchBlob(file, onProgress, signal);
|
||||
} catch (e) {
|
||||
if (!(e instanceof TypeError) || signal?.aborted) throw e;
|
||||
throw new Error(`Could not download ${file} from ${new URL(fileUrl(file)).host}`
|
||||
+ " — check the connection and press Start again", { cause: e });
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchBlob(file, onProgress, signal) {
|
||||
const url = fileUrl(file);
|
||||
const res = await fetch(url, { mode: "cors", signal });
|
||||
if (!res.ok) throw new Error(`${file}: HTTP ${res.status}`);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ export async function recalc(flashBytes, imei, esn) {
|
|||
const rc = M._sr_recalc(imeiPtr, esn >>> 0, SKEY, completePtr, logPtr, LOG_CAP);
|
||||
const log = M.UTF8ToString(logPtr);
|
||||
if (rc < 0) {
|
||||
const e = new Error("Not a recognizable Siemens fullflash layout");
|
||||
const e = new Error("Not a recognizable Siemens fullflash layout — "
|
||||
+ "pick “Run as is” under Advanced ▸ Siemens keys, or check the device");
|
||||
e.recalcLog = log;
|
||||
throw e;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue