Skip to content
Snippets Groups Projects
Commit ef860208 authored by Josefine Wegert's avatar Josefine Wegert
Browse files

downloader works with each alone and both together

parent 40a821cc
No related branches found
No related tags found
No related merge requests found
...@@ -174,7 +174,10 @@ function streamFilesToZip(){ ...@@ -174,7 +174,10 @@ function streamFilesToZip(){
backendContent = fs.readFileAsync(file.path); backendContent = fs.readFileAsync(file.path);
backendContent.then(function(data){ backendContent.then(function(data){
addBackendToZip(data).then(function(){ addBackendToZip(data).then(function(){
resolve(finishedArray.push('backend finished')); finishedArray.push('backend finished');
if(finishedArray.length === promiseArray.length){
resolve(zip);
}
}) })
...@@ -193,7 +196,10 @@ function streamFilesToZip(){ ...@@ -193,7 +196,10 @@ function streamFilesToZip(){
}).on('finish', function(){ }).on('finish', function(){
console.log('zip in frontend:', zip); console.log('zip in frontend:', zip);
resolve(finishedArray.push('frontend finished')); finishedArray.push('frontend finished');
if(finishedArray.length === promiseArray.length){
resolve(zip);
}
console.log('finishedArray in frontend:', finishedArray); console.log('finishedArray in frontend:', finishedArray);
...@@ -213,24 +219,10 @@ function streamFilesToZip(){ ...@@ -213,24 +219,10 @@ function streamFilesToZip(){
}) })
} }
function collectFilesToZip(finishedArray){
console.log('in collectFilesToZip');
console.log('finishedArray.length:', finishedArray.length);
console.log('promiseArray.length:', promiseArray.length);
return new Promise((resolve,reject)=> {
if(finishedArray.length === promiseArray.length){
console.log('in resolve()');
resolve(zip);
}
})
}
function finalizeZip(){ function finalizeZip(){
return streamFilesToZip().then(function(){ return streamFilesToZip().then(function(zip){
return collectFilesToZip(finishedArray).then(function(zip){
return createZip(zip) return createZip(zip)
})
}).catch(function(error) {let response = }).catch(function(error) {let response =
'There was an error during your build. ' + 'There was an error during your build. ' +
'Please contact "explorviz-developers-request@listserv.dfn.de" ' + 'Please contact "explorviz-developers-request@listserv.dfn.de" ' +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment