workaround for minibrowser flashrom download restarting

This commit is contained in:
zefie
2023-08-28 18:58:45 -04:00
parent bd9b85beb3
commit c41d535ce7
3 changed files with 33 additions and 10 deletions

View File

@@ -6,6 +6,15 @@ if (!request_headers.query.path) {
var 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 {
var 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));
var request_path = request_headers.query.path;
@@ -15,6 +24,7 @@ if (!request_headers.query.path) {
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') {
@@ -26,11 +36,11 @@ async function processLC2DownloadPage(flashrom_info, headers, numparts = null) {
}
if (numparts != null) flashrom_info.part_count = parseInt(numparts);
if (!flashrom_info.part_count) flashrom_info.part_count = parseInt(flashrom_info.message.substring(flashrom_info.message.length - 4).replace(/\D/g, ''));
console.log(flashrom_info);
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 = request_headers.request_url.replace(escape(request_headers.query.path), escape(flashrom_info.next_rompath.replace(service_name+":/","")));
}

View File

@@ -2,13 +2,14 @@ var minisrv_service_file = true;
headers = `200 OK
Content-type: text/html
wtv-expire-all: wtv-flashrom:
minisrv-no-mail-count: true`
data = `<html>
<head>
<title>
Updating
Updating complete
</title>
<display switchtowebmode nostatus nooptions skipback clearback>

View File

@@ -35,6 +35,7 @@
<SubType>Code</SubType>
</Content>
<Content Include="includes\classes\WTVAdmin.js" />
<Content Include="includes\classes\WTVAuthor.js" />
<Content Include="includes\classes\WTVBGMusic.js" />
<Content Include="includes\classes\WTVClientCapabilities.js" />
<Content Include="includes\classes\WTVClientSessionData.js" />
@@ -416,6 +417,15 @@
<Content Include="includes\ServiceVault\wtv-author\show-blocks.js" />
<Content Include="includes\ServiceVault\wtv-author\styles.js" />
<Content Include="includes\ServiceVault\wtv-author\templates.js" />
<Content Include="includes\ServiceVault\wtv-flashrom\content\content-serve.js" />
<Content Include="includes\ServiceVault\wtv-flashrom\current-noflash.js" />
<Content Include="includes\ServiceVault\wtv-flashrom\get-by-path.js" />
<Content Include="includes\ServiceVault\wtv-flashrom\get-lc2-page.js" />
<Content Include="includes\ServiceVault\wtv-flashrom\initiate-lc2-download.js" />
<Content Include="includes\ServiceVault\wtv-flashrom\lc2-download-complete.js" />
<Content Include="includes\ServiceVault\wtv-flashrom\lc2-download-failed.js" />
<Content Include="includes\ServiceVault\wtv-flashrom\noflash.js" />
<Content Include="includes\ServiceVault\wtv-flashrom\willie.js" />
<Content Include="includes\ServiceVault\wtvchat\catchall.js">
<SubType>Code</SubType>
</Content>
@@ -2573,6 +2583,8 @@
<Folder Include="includes\ServiceVault\wtv-author\samples_en-US\HollisBaseballLeague\" />
<Folder Include="includes\ServiceVault\wtv-author\samples_en-US\media\" />
<Folder Include="includes\ServiceVault\wtv-author\samples_en-US\WilsonFamilySummer\" />
<Folder Include="includes\ServiceVault\wtv-flashrom\" />
<Folder Include="includes\ServiceVault\wtv-flashrom\content\" />
<Folder Include="includes\ServiceVault\wtvchat\" />
<Folder Include="includes\ServiceVault\news\" />
<Folder Include="includes\ServiceVault\SharedROMCache\" />