Skip to content

Commit

Permalink
Merge pull request #422 from FAIMS/fix-zip-and-csv-download-bug
Browse files Browse the repository at this point in the history
Fix bug in download
  • Loading branch information
stevecassidy authored Jun 9, 2024
2 parents 9c0b9be + d8fe71c commit 044e589
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"express-handlebars": "7.1.2",
"express-rate-limit": "^7.1.5",
"express-validator": "7.0.1",
"faims3-datamodel": "github:FAIMS/faims3-data-model#v1.1.1",
"faims3-datamodel": "github:FAIMS/faims3-data-model#v1.1.5",
"fast-check": "2.25.0",
"gts": "3.1.1",
"handlebars": "4.7.7.",
Expand Down
16 changes: 12 additions & 4 deletions src/couchdb/notebooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,10 @@ const csvFormatValue = (
if (value instanceof Array) {
result[fieldName] = value
.map((v: any) => {
return `${v.relation_type_vocabPair[0]}/${v.record_id}`;
const relation_name = v.relation_type_vocabPair
? v.relation_type_vocabPair[0]
: 'unknown relation';
return `${relation_name}/${v.record_id}`;
})
.join(';');
} else {
Expand Down Expand Up @@ -809,8 +812,12 @@ export const streamNotebookFilesAsZip = async (
allFilesAdded &&
ev.entries.total === ev.entries.processed
) {
archive.finalize();
doneFinalize = true;
try {
archive.finalize();
doneFinalize = true;
} catch {
// ignore ArchiveError
}
}
});

Expand Down Expand Up @@ -862,7 +869,8 @@ export const streamNotebookFilesAsZip = async (
}
// if we didn't write any data then finalise because that won't happen elsewhere
if (!dataWritten) {
archive.finalize();
console.log('no data written');
archive.abort();
}
allFilesAdded = true;
// fire a progress event here because short/empty zip files don't
Expand Down

0 comments on commit 044e589

Please sign in to comment.