Skip to content

Commit

Permalink
don't fall over when relation name is missing
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Cassidy <[email protected]>
  • Loading branch information
stevecassidy committed Jun 9, 2024
1 parent 8c6846d commit d8fe71c
Showing 1 changed file with 12 additions and 4 deletions.
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}`;

Check warning on line 643 in src/couchdb/notebooks.ts

View check run for this annotation

Codecov / codecov/patch

src/couchdb/notebooks.ts#L643

Added line #L643 was not covered by tests
})
.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();

Check warning on line 873 in src/couchdb/notebooks.ts

View check run for this annotation

Codecov / codecov/patch

src/couchdb/notebooks.ts#L872-L873

Added lines #L872 - L873 were not covered by tests
}
allFilesAdded = true;
// fire a progress event here because short/empty zip files don't
Expand Down

0 comments on commit d8fe71c

Please sign in to comment.