From c155a278e3daa576a0973f2cc224fc8c73128a72 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 2 Nov 2016 17:34:27 +0100 Subject: [PATCH] another bugfix #2 --- src/trigger/parser.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/trigger/parser.js b/src/trigger/parser.js index 9c997a5..80af912 100644 --- a/src/trigger/parser.js +++ b/src/trigger/parser.js @@ -50,7 +50,7 @@ module.exports = (lib) => { } else { fs.stat('./b/' + cb.file, (err, stat) => { - if(err === null || err.code == 'ENOENT') + if(err === null) fs.unlinkSync('./b/' + cb.file); if(cb.msg !== '') e.reply(cb.msg); @@ -179,18 +179,22 @@ module.exports = (lib) => { if(size > cfg.maxFileSize) cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(size)+'), max '+lib.formatSize(cfg.maxFileSize)+' allowed' }); else { - lib.getCheckSum('./b/' + tmpdest, (cbcs) => { - lib.checkRepostCheckSum(cbcs, (cbcrcs) => { - if(cbcrcs === true) { - var mime = fileType(readChunk.sync('./b/' + tmpdest, 0, 262)); - if(cfg.allowedMimes.hasOwnProperty(mime.mime) || info.type === 'soundcloud') - cb({ success: true, info: info, size: size, file: './b/' + tmpdest, checksum: cbcs }); - else - cb({ success: false, file: tmpdest, msg: 'lol, go f0ck yourself ('+mime+')' }); - } - else - cb({ success: false, file: tmpdest, msg: 'repost motherf0cker: '+cfg.url+'/'+cbcrcs }); - }); + fs.stat('./b/' + cb.file, (err, stat) => { + if(err === null) { + lib.getCheckSum('./b/' + tmpdest, (cbcs) => { + lib.checkRepostCheckSum(cbcs, (cbcrcs) => { + if(cbcrcs === true) { + var mime = fileType(readChunk.sync('./b/' + tmpdest, 0, 262)); + if(cfg.allowedMimes.hasOwnProperty(mime.mime) || info.type === 'soundcloud') + cb({ success: true, info: info, size: size, file: './b/' + tmpdest, checksum: cbcs }); + else + cb({ success: false, file: tmpdest, msg: 'lol, go f0ck yourself ('+mime+')' }); + } + else + cb({ success: false, file: tmpdest, msg: 'repost motherf0cker: '+cfg.url+'/'+cbcrcs }); + }); + }); + } }); } })