This commit is contained in:
Flummi 2016-11-02 17:49:40 +01:00
parent 3969b0a092
commit 068d6b17e4
2 changed files with 10 additions and 10 deletions

2
bot.js
View File

@ -26,7 +26,7 @@ var child = new (forever.Monitor)(__dirname+'/src/main.js', {
silent: false, silent: false,
cwd: __dirname, cwd: __dirname,
args: [], args: [],
spinSleepTime: 2000, spinSleepTime: 5000,
watch: true, watch: true,
watchIgnoreDotFiles: true, watchIgnoreDotFiles: true,
watchIgnorePatterns: [ watchIgnorePatterns: [

View File

@ -84,7 +84,7 @@ module.exports = (lib) => {
.on('response', (res) => { .on('response', (res) => {
if(res.headers['content-length'] > cfg.maxFileSize) { if(res.headers['content-length'] > cfg.maxFileSize) {
res.destroy(); res.destroy();
dat.close(); dat.end();
cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(cfg.maxFileSize)+' allowed' }); cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(cfg.maxFileSize)+' allowed' });
} }
else { else {
@ -98,13 +98,13 @@ module.exports = (lib) => {
} }
}) })
.on('error', (err) => { .on('error', (err) => {
dat.close(); dat.end();
cb({ success: false, file: tmpdest, msg: ex }); cb({ success: false, file: tmpdest, msg: err.message });
}) })
.pipe(dat); .pipe(dat);
} }
catch(ex) { catch(ex) {
dat.close(); dat.end();
cb({ success: false, file: tmpdest, msg: ex.message }); cb({ success: false, file: tmpdest, msg: ex.message });
} }
} }
@ -125,7 +125,7 @@ module.exports = (lib) => {
}; };
} }
else { else {
dat.close(); dat.end();
cb({ success: false, file: tmpdest, msg: 'f0ck sc-api' }); cb({ success: false, file: tmpdest, msg: 'f0ck sc-api' });
} }
}); });
@ -156,17 +156,17 @@ module.exports = (lib) => {
}; };
} }
else { else {
dat.close(); dat.end();
cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(data.length)+'), max '+lib.formatSize(cfg.maxFileSize)+' allowed' }); cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(data.length)+'), max '+lib.formatSize(cfg.maxFileSize)+' allowed' });
} }
} }
else { else {
dat.close(); dat.end();
cb({ success: false, file: tmpdest, msg: '' }); cb({ success: false, file: tmpdest, msg: '' });
} }
} }
else { else {
dat.close(); dat.end();
cb({ success: false, file: tmpdest, msg: err }); cb({ success: false, file: tmpdest, msg: err });
} }
}); });
@ -175,7 +175,7 @@ module.exports = (lib) => {
dat dat
.on('finish', () => { .on('finish', () => {
var size = dat.bytesWritten; var size = dat.bytesWritten;
dat.close(); dat.end();
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 {