fix: Empty collection causes export failure

closes #1043
This commit is contained in:
Tom Moor
2019-10-12 19:31:15 -07:00
parent ec4d4fb20f
commit 65b8fb40f3

View File

@ -34,7 +34,11 @@ async function archiveToPath(zip) {
export async function archiveCollection(collection: Collection) { export async function archiveCollection(collection: Collection) {
const zip = new JSZip(); const zip = new JSZip();
await addToArchive(zip, collection.documentStructure);
if (collection.documentStructure) {
await addToArchive(zip, collection.documentStructure);
}
return archiveToPath(zip); return archiveToPath(zip);
} }
@ -42,8 +46,10 @@ export async function archiveCollections(collections: Collection[]) {
const zip = new JSZip(); const zip = new JSZip();
for (const collection of collections) { for (const collection of collections) {
const folder = zip.folder(collection.name); if (collection.documentStructure) {
await addToArchive(folder, collection.documentStructure); const folder = zip.folder(collection.name);
await addToArchive(folder, collection.documentStructure);
}
} }
return archiveToPath(zip); return archiveToPath(zip);
} }