From 1da90668760aa2b4a202b88adee5ecf693396912 Mon Sep 17 00:00:00 2001 From: Flamelord626 <161178045+Flamelord626@users.noreply.github.com> Date: Fri, 18 Jul 2025 02:43:45 +0100 Subject: [PATCH] Flashrom Download Time Calculation (#34) works good enough need to fix it thinking that the client is both an lc2 and a classic when haveing a moment --- .../ServiceVault/wtv-flashrom/get-lc2-page.js | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/get-lc2-page.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/get-lc2-page.js index c2efb76b..0a6b5bda 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/get-lc2-page.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/get-lc2-page.js @@ -42,12 +42,44 @@ async function processLC2DownloadPage(flashrom_info, headers, numparts = null) { } if (!flashrom_info.is_last_part) { - flashrom_info.next_rompath = request_headers.request_url.replace(escape(request_headers.query.path), escape(flashrom_info.next_rompath.replace(service_name+":/",""))); + flashrom_info.next_rompath = request_headers.request_url.replace( + escape(request_headers.query.path), + escape(flashrom_info.next_rompath.replace(service_name + ":/", "")) + ); } + + 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` +minisrv-no-mail-count: true`; data = ` @@ -98,7 +130,7 @@ Updating now Your ${session_data.getBoxName()} is being
updated automatically.

-This will take a while, and
then you can use your ${session_data.getBoxName()} again. +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 += `

@@ -107,7 +139,7 @@ This will take a while, and
then you can use your ${session_data.getBoxName() during this time. ` } -data += ` + data += `