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,6 +179,8 @@ 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 {
fs.stat('./b/' + cb.file, (err, stat) => {
if(err === null) {
lib.getCheckSum('./b/' + tmpdest, (cbcs) => { lib.getCheckSum('./b/' + tmpdest, (cbcs) => {
lib.checkRepostCheckSum(cbcs, (cbcrcs) => { lib.checkRepostCheckSum(cbcs, (cbcrcs) => {
if(cbcrcs === true) { if(cbcrcs === true) {
@ -193,6 +195,8 @@ module.exports = (lib) => {
}); });
}); });
} }
});
}
}) })
.on('error', (err) => { .on('error', (err) => {
cb({ success: false, file: tmpdest, msg: err }); cb({ success: false, file: tmpdest, msg: err });