From 7aedcb7447f1bfd10d0c12233594ffb1e0473fbd Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 5 Jan 2017 23:49:56 +0100 Subject: changes: Clean up /tmp files after diffing --- modules/changes/changes.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/changes/changes.js b/modules/changes/changes.js index 8a0b3d9..3c75671 100644 --- a/modules/changes/changes.js +++ b/modules/changes/changes.js @@ -436,12 +436,21 @@ module.exports=function(app,io,_moddir){ } counter++; if(counter<2)return; + var proc=child_process.spawn( "diff", [folder+"/old.html",folder+"/new.html"], {stdio:[process.stdin,fs.openSync(folder+"/diff.txt","w"),process.stderr]}); + proc.on("exit",function(code,signal){ - fs.createReadStream(folder+"/diff.txt").pipe(res); + 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); + }); }); }; fs.writeFile(folder+"/old.html",tl[oldi][2],fscb); -- cgit v1.2.3-70-g09d2