Add precondition for `writeAttachment`

pull/1/head
Daniel Gasienica 7 years ago
parent 0faaf52b71
commit 7eeabb5b1a

@ -20,6 +20,7 @@ const archiver = require('archiver');
const rimraf = require('rimraf');
const electronRemote = require('electron').remote;
const Attachment = require('./types/attachment');
const crypto = require('./crypto');
@ -493,6 +494,10 @@ async function writeAttachment(attachment, options) {
}
}
if (!Attachment.hasData(attachment)) {
throw new TypeError('"attachment.data" is required');
}
const encrypted = await crypto.encryptSymmetric(key, attachment.data);
const writer = await createFileAndWriter(dir, filename);

Loading…
Cancel
Save