Add precondition for writeAttachment
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user