add less than expected chunk count check

This commit is contained in:
Abhinav 2022-12-20 17:50:16 +05:30
parent 393831625b
commit 1bc67538eb
2 changed files with 2 additions and 1 deletions

View file

@ -23,7 +23,7 @@ export async function getFileHash(worker, file: File | ElectronFile) {
for (let i = 0; i < filedata.chunkCount; i++) {
const { done, value: chunk } = await streamReader.read();
if (done) {
break;
throw Error(CustomError.CHUNK_LESS_THAN_EXPECTED);
}
await worker.hashFileChunk(hashState, Uint8Array.from(chunk));
}

View file

@ -19,6 +19,7 @@ export enum CustomError {
KEY_MISSING = 'encrypted key missing from localStorage',
FAILED_TO_LOAD_WEB_WORKER = 'failed to load web worker',
CHUNK_MORE_THAN_EXPECTED = 'chunks more than expected',
CHUNK_LESS_THAN_EXPECTED = 'chunks less than expected',
UNSUPPORTED_FILE_FORMAT = 'unsupported file formats',
FILE_TOO_LARGE = 'file too large',
SUBSCRIPTION_EXPIRED = 'subscription expired',