Skip to content

Commit

Permalink
Throw errors for ipfs download
Browse files Browse the repository at this point in the history
  • Loading branch information
ColRad committed Feb 12, 2019
1 parent d71138d commit f89cdb9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ipfsControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ export async function download(filePath, symKey, iv, authTag, hash) {
return new Promise(async (resolve, reject) => {
try {
const stream = ipfsApi.catReadableStream(hash);
stream.on('error', (err) => {
console.log(`IPFS download error ${err}`);
reject(err);
});

const decipher = createDecipheriv(
'aes-256-gcm',
Buffer.from(symKey, 'latin1'),
Expand All @@ -247,8 +252,12 @@ export async function download(filePath, symKey, iv, authTag, hash) {
console.log(`Download decipher error ${err}`);
reject(err);
});

const output = createWriteStream(filePath);

output.on('error', (err) => {
console.log(`File system writing error ${err}`);
reject(err);
});
output.on('finish', () => {
resolve();
});
Expand Down

0 comments on commit f89cdb9

Please sign in to comment.