summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-12-31 17:39:36 +0100
committertomsmeding <tom.smeding@gmail.com>2019-12-31 17:39:36 +0100
commite747b5740d8ee3752da3daf27ccb2c220314a6ae (patch)
tree072a4b3bb2f67fc73961a2a5c70b2f7506834fb7 /modules
parent9ef099c2679047569aa2da0d688a919bf707e6c6 (diff)
changes: Better cleanup in diff
Diffstat (limited to 'modules')
-rw-r--r--modules/changes/changes.js15
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);