const minisrv_service_file = true; request_is_async = true; if (!request_headers.query.path) { const errpage = wtvshared.doErrorPage(400); headers = errpage[0]; data = errpage[1]; } else { if (request_headers.Referer === service_name + ":/lc2-download-complete?") { headers = `200 OK Content-type: text/html minisrv-no-mail-count: true wtv-visit: ${service_name}:/lc2-download-complete? Location: ${service_name}:/lc2-download-complete?` data = ''; sendToClient(socket, headers, data); } else { const wtvflashrom = new WTVFlashrom(minisrv_config, service_vaults, service_name, minisrv_config.services[service_name].use_zefie_server, false, (minisrv_config.services[service_name].debug ? false : true)); const request_path = request_headers.query.path; // read flashrom header info into array using WTVFlashrom class wtvflashrom.getFlashromMeta(request_path, function (data, headers) { processLC2DownloadPage(data, headers, (request_headers.query.numparts ? request_headers.query.numparts : null)); }); } } async function processLC2DownloadPage(flashrom_info, headers, numparts = null) { if (typeof flashrom_info === 'string') { // zefie_flashrom_server error data = flashrom_info; headers += "\nminisrv-no-mail-count: true\nwtv-expire-all: wtv-flashrom:/get-lc2-page?"; sendToClient(socket, headers, data); return false; } if (numparts !== null) flashrom_info.part_count = parseInt(numparts); if (!flashrom_info.part_count) flashrom_info.part_count = parseInt(flashrom_info.message.slice(flashrom_info.message.length - 4).replace(/\D/g, '')); if (parseInt(flashrom_info.part_number) >= 0 && flashrom_info.rompath && flashrom_info.next_rompath) { if (!flashrom_info.message && flashrom_info.is_bootrom) { flashrom_info.message = "BootRom Part " + (flashrom_info.part_number + 1) + " of " + flashrom_info.part_count; } if (!flashrom_info.is_last_part) { flashrom_info.next_rompath = service_name + ":/get-lc2-page?path=" + wtvshared.escape(flashrom_info.next_rompath.replace(service_name + ":/", "")); } console.log(flashrom_info.next_rompath); const romtype = ssid_sessions[socket.ssid].get("wtv-client-rom-type"); let defaultDownloadTime; switch (romtype) { case "US-LC2-disk-0MB-8MB": case "US-LC2-disk-0MB-8MB-softmodem-CPU5230": case "US-LC2-flashdisk-0MB-16MB-softmodem-CPU5230": case "US-WEBSTAR-disk-0MB-16MB-softmodem-CPU5230": case "US-DTV-disk-0MB-32MB-softmodem-CPU5230": defaultDownloadTime = 30; break; case "US-BPS-flashdisk-0MB-8MB-softmodem-CPU5230": defaultDownloadTime = 20; break; default: defaultDownloadTime = 15; break; } let downloadTime = defaultDownloadTime; const session = ssid_sessions[socket.ssid]; const now = Date.now(); if (session.lastDownloadTime) { const elapsedMinutes = Math.ceil((now - session.lastDownloadTime) / 60000); const remainingParts = flashrom_info.part_count - flashrom_info.part_number - 1; downloadTime = elapsedMinutes * remainingParts; } session.lastDownloadTime = now; headers = `200 OK Content-type: text/html minisrv-no-mail-count: true`; data = ` Updating

Updating now
Your ${session_data.getBoxName()} is being
updated automatically.

This will take about ${downloadTime} minutes and
then you can use your ${session_data.getBoxName()} again. `; if (flashrom_info.is_bootrom && flashrom_info.part_number === (flashrom_info.part_count - 1)) { data += `

The system will pause for about 30 seconds at the end of this update. Please do not interrupt the system during this time. ` } data += `




` : `>`}

${flashrom_info.message}

`; } else { const errpage = wtvshared.doErrorPage(400); headers = errpage[0]; headers += "\nminisrv-no-mail-count: true\nwtv-expire-all: wtv-flashrom:/get-lc2-page?"; data = errpage[1]; } sendToClient(socket, headers, data); }