Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use sync to write files for simplicity

  • Loading branch information...
commit 3adeda057f48879744db32ed8698eff17348faf9 1 parent e87023d
Kris Zyp authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/jsgi/archive.js
12 lib/jsgi/archive.js
View
@@ -48,19 +48,19 @@ function cacheArchive(url){
return "http://" + host + cachedUrl;
}
return request({url:url, encoding:"binary"}).then(function(response){
- var file = fs.open("public/" + cachedUrl, "w");
+ var file = fs.openSync("public/" + cachedUrl, "w");
var size = 0;
return response.body.forEach(function(part){
size += part.length;
if(size > maxSize){
- file.close();
- fs.open("public/" + cachedUrl, "w");
- file.write("redirect to: " + url);
+ fs.closeSync(file);
+ file = fs.openSync("public/" + cachedUrl, "w");
+ file.writeSync("redirect to: " + url);
return true;
}
- file.write(part, null, "binary");
+ file.writeSync(part, null, "binary");
}).then(function(){
- file.close();
+ file.closeSync();
});
}).then(null, function(e){
print(e.stack);
Please sign in to comment.
Something went wrong with that request. Please try again.