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 {
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 });
});
});
}
});
}
})