another bugfix #2

This commit is contained in:
Flummi 2016-11-02 17:34:27 +01:00
parent 2788ad9e38
commit c155a278e3

View File

@ -50,7 +50,7 @@ module.exports = (lib) => {
} }
else { else {
fs.stat('./b/' + cb.file, (err, stat) => { fs.stat('./b/' + cb.file, (err, stat) => {
if(err === null || err.code == 'ENOENT') if(err === null)
fs.unlinkSync('./b/' + cb.file); fs.unlinkSync('./b/' + cb.file);
if(cb.msg !== '') if(cb.msg !== '')
e.reply(cb.msg); e.reply(cb.msg);
@ -179,18 +179,22 @@ module.exports = (lib) => {
if(size > cfg.maxFileSize) 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' }); cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(size)+'), max '+lib.formatSize(cfg.maxFileSize)+' allowed' });
else { else {
lib.getCheckSum('./b/' + tmpdest, (cbcs) => { fs.stat('./b/' + cb.file, (err, stat) => {
lib.checkRepostCheckSum(cbcs, (cbcrcs) => { if(err === null) {
if(cbcrcs === true) { lib.getCheckSum('./b/' + tmpdest, (cbcs) => {
var mime = fileType(readChunk.sync('./b/' + tmpdest, 0, 262)); lib.checkRepostCheckSum(cbcs, (cbcrcs) => {
if(cfg.allowedMimes.hasOwnProperty(mime.mime) || info.type === 'soundcloud') if(cbcrcs === true) {
cb({ success: true, info: info, size: size, file: './b/' + tmpdest, checksum: cbcs }); var mime = fileType(readChunk.sync('./b/' + tmpdest, 0, 262));
else if(cfg.allowedMimes.hasOwnProperty(mime.mime) || info.type === 'soundcloud')
cb({ success: false, file: tmpdest, msg: 'lol, go f0ck yourself ('+mime+')' }); cb({ success: true, info: info, size: size, file: './b/' + tmpdest, checksum: cbcs });
} else
else cb({ success: false, file: tmpdest, msg: 'lol, go f0ck yourself ('+mime+')' });
cb({ success: false, file: tmpdest, msg: 'repost motherf0cker: '+cfg.url+'/'+cbcrcs }); }
}); else
cb({ success: false, file: tmpdest, msg: 'repost motherf0cker: '+cfg.url+'/'+cbcrcs });
});
});
}
}); });
} }
}) })