Skip to content

Commit

Permalink
fix: parse zipped brew and bean data correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelblijleven committed Jun 30, 2023
1 parent a4a0dc2 commit 4c1c5d1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lib/upload/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function readZipFile(file: File, callback: (data: any) => void) {
const blobReader = new BlobReader(file);
const reader = new ZipReader(blobReader);
const entries: Entry[] = await reader.getEntries();
console.log(entries)

if (!entries.length) {
throw new Error("Empty zip file uploaded");
}
Expand All @@ -51,16 +51,17 @@ export async function readZipFile(file: File, callback: (data: any) => void) {
const data = await readEntryToJSON(entry);

if (!!entry.filename.match(BEANCONQUEROR_BEANS_RE)) {
additionalBeans.push(data.BEANS);
additionalBeans.push(...data);
continue;
}

if (!!entry.filename.match(BEANCONQUEROR_BREWS_RE)) {
additionalBrews.push(data.BREWS);
additionalBrews.push(...data);
}
}
baseData.BEANS = baseData.BEANS.concat(...additionalBeans);
baseData.BREWS = baseData.BREWS.concat(...additionalBrews);

baseData.BEANS = baseData.BEANS.concat(additionalBeans);
baseData.BREWS = baseData.BREWS.concat(additionalBrews);

await callback(baseData);
await reader.close();
Expand Down

0 comments on commit 4c1c5d1

Please sign in to comment.