diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/changes/changes.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/changes/changes.js b/modules/changes/changes.js index d4c48e2..302628b 100644 --- a/modules/changes/changes.js +++ b/modules/changes/changes.js @@ -435,9 +435,17 @@ module.exports=function(app,io,_moddir){ res.send(); return; } + function cleanup() { + try { fs.unlinkSync(folder+"/old.html"); } catch(e) { console.log(e); } + try { fs.unlinkSync(folder+"/new.html"); } catch(e) { console.log(e); } + try { fs.unlinkSync(folder+"/diff.txt"); } catch(e) { console.log(e); } + try { fs.rmdirSync(folder); } catch(e) { console.log(e); } + } + var counter=0; var fscb=function(err){ if(err){ + cleanup(); console.log(err); res.status(500); res.send(); @@ -454,12 +462,7 @@ module.exports=function(app,io,_moddir){ proc.on("exit",function(code,signal){ var stream=fs.createReadStream(folder+"/diff.txt"); stream.pipe(res); - stream.on("end",function(){ - fs.unlinkSync(folder+"/old.html"); - fs.unlinkSync(folder+"/new.html"); - fs.unlinkSync(folder+"/diff.txt"); - fs.rmdirSync(folder); - }); + stream.on("end",cleanup); }); }; fs.writeFile(folder+"/old.html",tl[oldi][2],fscb); |