
var fs = require('fs');
var path = require('path');

module.exports = function(jobid, conf){

    var executionmethods = require('./executionserver.methods')(conf);

    var cwd = path.join(conf.storagedir, jobid);
    
    executionmethods.deleteFolderRecursive(cwd);
    var compressed = cwd + ".tar.gz";
    var compressedstat;
    try{
        compressedstat = fs.statSync(compressed);
    }catch(e){
        //does not exist
        compressedstat = undefined;
    }
    if(compressedstat){
        fs.unlinkSync(compressed);
    }
        
    
}
@@ -84,16 +84,21 @@
 id, conf
+, doc
 )%7B%0A%0A    
@@ -165,16 +165,420 @@
 conf);%0A%0A
+    var promdoc; %0A%0A    if(doc)%7B%0A        promdoc = Promise.resolve(doc);%0A    %7Delse%7B%0A        promdoc = executionmethods.getDocument(jobid)%0A        .catch(function(err)%7B%0A            console.error(%22Job not found before delete.%22, jobid)%0A        %7D);%0A    %7D%0A%0A    return promdoc%0A    .then(function(doc)%7B        %0A        return require(path.join(__dirname, %22jobkill%22))(doc, conf);%0A    %7D)%0A    .then(function()%7B%0A    
     var 
@@ -619,24 +619,45 @@
 obid);%0A    %0A
+        try%7B%0A        
     executio
@@ -689,24 +689,32 @@
 rsive(cwd);%0A
+        
     var comp
@@ -739,16 +739,24 @@
 ar.gz%22;%0A
+        
     var 
@@ -775,29 +775,44 @@
 at;%0A    
-try%7B%0A
+        try%7B%0A       
         
 compress
@@ -795,32 +795,33 @@
 %0A               
+ 
 compressedstat =
@@ -842,24 +842,32 @@
 ompressed);%0A
+        
     %7Dcatch(e
@@ -877,16 +877,24 @@
         
+  
+      
 //does n
@@ -902,32 +902,40 @@
 t exist%0A        
+    
+    
 compressedstat =
@@ -946,26 +946,42 @@
 efined;%0A    
-%7D%0A
+        %7D%0A        
     if(compr
@@ -1000,16 +1000,24 @@
         
+  
+      
 fs.unlin
@@ -1035,25 +1035,213 @@
 essed);%0A    
-%7D
+        %7D%0A        %7Dcatch(e)%7B%0A            return %7B%0A                error: e%0A            %7D%0A        %7D%0A        %0A%0A        return %7B%0A            status: %22Folder deleted %22 + jobid%0A        %7D%0A    %7D);
 %0A        %0A  

Check if the job is running.