Add precondition for writeAttachment
This commit is contained in:
parent
0faaf52b71
commit
7eeabb5b1a
1 changed files with 5 additions and 0 deletions
|
@ -20,6 +20,7 @@ const archiver = require('archiver');
|
||||||
const rimraf = require('rimraf');
|
const rimraf = require('rimraf');
|
||||||
const electronRemote = require('electron').remote;
|
const electronRemote = require('electron').remote;
|
||||||
|
|
||||||
|
const Attachment = require('./types/attachment');
|
||||||
const crypto = require('./crypto');
|
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 encrypted = await crypto.encryptSymmetric(key, attachment.data);
|
||||||
|
|
||||||
const writer = await createFileAndWriter(dir, filename);
|
const writer = await createFileAndWriter(dir, filename);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue