Loading app/src/controller.manager.js +3 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,9 @@ export class Controller { (loaded, total, name) => { this.view.onUnzip(name, loaded, total); }, (loaded, total, name) => { this.view.onVerify(name, loaded, total); }, ); this.view.onDownloadingEnd(); return true; Loading app/src/controller/device.manager.js +2 −1 Original line number Diff line number Diff line Loading @@ -185,13 +185,14 @@ export class DeviceManager { } } async downloadAll(onProgress, onUnzip) { async downloadAll(onProgress, onUnzip, onVerify) { try { await this.downloader.downloadAndUnzipFolder( this.files, this.folder, onProgress, onUnzip, onVerify, ); } catch (e) { throw new Error(`downloadAll error ${e.message || e}`); Loading app/src/controller/downloader.manager.js +11 −4 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ export class Downloader { folder, onDownloadProgress, onUnzipProgress, onVerifyProgress, ) { let current_file; try { Loading @@ -55,7 +56,9 @@ export class Downloader { const expected = await this.fetchChecksum( `${file.path}.sha256sum`, ); const actual = await this.computeSha256(blob); const actual = await this.computeSha256(blob, (loaded, total) => { onVerifyProgress(loaded, total, file.name) }); if (expected && actual !== expected) { throw new Error( `Checksum mismatch for ${file.name}: expected ${expected} got ${actual}`, Loading Loading @@ -91,7 +94,9 @@ export class Downloader { if (filesRequired.includes(filename)) { await this.setInDBStore(unzippedEntry.blob, filename); this.stored[filename] = true; const fileSHA = await this.computeSha256(unzippedEntry.blob); const fileSHA = await this.computeSha256(unzippedEntry.blob, (loaded, total) => { onVerifyProgress(loaded, total, filename) }); console.log(`File: ${unzippedEntry.name} SHA256: ${fileSHA}`); } } Loading Loading @@ -155,16 +160,18 @@ export class Downloader { * Streaming SHA-256 computation for large files. * Processes blob in 16MB chunks to avoid memory limits on low-memory devices. */ async computeSha256(blob) { async computeSha256(blob, onVerifyProgress) { const CHUNK_SIZE = 16 * 1024 * 1024; // 16MB chunks const hasher = await createSHA256(); const blobSize = blob.size; hasher.init(); let offset = 0; while (offset < blob.size) { while (offset < blobSize) { const chunk = blob.slice(offset, offset + CHUNK_SIZE); const buffer = await chunk.arrayBuffer(); hasher.update(new Uint8Array(buffer)); onVerifyProgress(offset, blobSize); offset += CHUNK_SIZE; } Loading app/src/viewManager.js +15 −0 Original line number Diff line number Diff line Loading @@ -145,6 +145,21 @@ export default class ViewManager { this.WDebug.log(`Downloading ${name}: ${v}/${100}`, `downloading-${name}`); } onVerify(name, loaded, total) { const v = Math.round((loaded / total) * 100); let $progressBar = document.querySelector( `.active .downloading-progress-bar`, ); let $progress = document.querySelector(`.active .downloading-progress`); if ($progressBar) { $progressBar.value = v; } if ($progress) { $progress.innerText = `Verifying ${name}: ${v}/${100}`; } this.WDebug.log(`Verifying ${name}: ${v}/${100}`, `verifying-${name}`); } onUnzip(name, loaded, total) { const v = Math.round((loaded / total) * 100); let $progressBar = document.querySelector( Loading Loading
app/src/controller.manager.js +3 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,9 @@ export class Controller { (loaded, total, name) => { this.view.onUnzip(name, loaded, total); }, (loaded, total, name) => { this.view.onVerify(name, loaded, total); }, ); this.view.onDownloadingEnd(); return true; Loading
app/src/controller/device.manager.js +2 −1 Original line number Diff line number Diff line Loading @@ -185,13 +185,14 @@ export class DeviceManager { } } async downloadAll(onProgress, onUnzip) { async downloadAll(onProgress, onUnzip, onVerify) { try { await this.downloader.downloadAndUnzipFolder( this.files, this.folder, onProgress, onUnzip, onVerify, ); } catch (e) { throw new Error(`downloadAll error ${e.message || e}`); Loading
app/src/controller/downloader.manager.js +11 −4 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ export class Downloader { folder, onDownloadProgress, onUnzipProgress, onVerifyProgress, ) { let current_file; try { Loading @@ -55,7 +56,9 @@ export class Downloader { const expected = await this.fetchChecksum( `${file.path}.sha256sum`, ); const actual = await this.computeSha256(blob); const actual = await this.computeSha256(blob, (loaded, total) => { onVerifyProgress(loaded, total, file.name) }); if (expected && actual !== expected) { throw new Error( `Checksum mismatch for ${file.name}: expected ${expected} got ${actual}`, Loading Loading @@ -91,7 +94,9 @@ export class Downloader { if (filesRequired.includes(filename)) { await this.setInDBStore(unzippedEntry.blob, filename); this.stored[filename] = true; const fileSHA = await this.computeSha256(unzippedEntry.blob); const fileSHA = await this.computeSha256(unzippedEntry.blob, (loaded, total) => { onVerifyProgress(loaded, total, filename) }); console.log(`File: ${unzippedEntry.name} SHA256: ${fileSHA}`); } } Loading Loading @@ -155,16 +160,18 @@ export class Downloader { * Streaming SHA-256 computation for large files. * Processes blob in 16MB chunks to avoid memory limits on low-memory devices. */ async computeSha256(blob) { async computeSha256(blob, onVerifyProgress) { const CHUNK_SIZE = 16 * 1024 * 1024; // 16MB chunks const hasher = await createSHA256(); const blobSize = blob.size; hasher.init(); let offset = 0; while (offset < blob.size) { while (offset < blobSize) { const chunk = blob.slice(offset, offset + CHUNK_SIZE); const buffer = await chunk.arrayBuffer(); hasher.update(new Uint8Array(buffer)); onVerifyProgress(offset, blobSize); offset += CHUNK_SIZE; } Loading
app/src/viewManager.js +15 −0 Original line number Diff line number Diff line Loading @@ -145,6 +145,21 @@ export default class ViewManager { this.WDebug.log(`Downloading ${name}: ${v}/${100}`, `downloading-${name}`); } onVerify(name, loaded, total) { const v = Math.round((loaded / total) * 100); let $progressBar = document.querySelector( `.active .downloading-progress-bar`, ); let $progress = document.querySelector(`.active .downloading-progress`); if ($progressBar) { $progressBar.value = v; } if ($progress) { $progress.innerText = `Verifying ${name}: ${v}/${100}`; } this.WDebug.log(`Verifying ${name}: ${v}/${100}`, `verifying-${name}`); } onUnzip(name, loaded, total) { const v = Math.round((loaded / total) * 100); let $progressBar = document.querySelector( Loading