From 65b8fb40f3f08a7fe9c8ffe028f4e6cb97873654 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 12 Oct 2019 19:31:15 -0700 Subject: [PATCH] fix: Empty collection causes export failure closes #1043 --- server/utils/zip.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/utils/zip.js b/server/utils/zip.js index f4cbfe03..3b11d2ae 100644 --- a/server/utils/zip.js +++ b/server/utils/zip.js @@ -34,7 +34,11 @@ async function archiveToPath(zip) { export async function archiveCollection(collection: Collection) { const zip = new JSZip(); - await addToArchive(zip, collection.documentStructure); + + if (collection.documentStructure) { + await addToArchive(zip, collection.documentStructure); + } + return archiveToPath(zip); } @@ -42,8 +46,10 @@ export async function archiveCollections(collections: Collection[]) { const zip = new JSZip(); for (const collection of collections) { - const folder = zip.folder(collection.name); - await addToArchive(folder, collection.documentStructure); + if (collection.documentStructure) { + const folder = zip.folder(collection.name); + await addToArchive(folder, collection.documentStructure); + } } return archiveToPath(zip); }