Browse files

Use sync to write files for simplicity

  • Loading branch information...
1 parent e87023d commit 3adeda057f48879744db32ed8698eff17348faf9 @kriszyp committed Jun 20, 2011
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/jsgi/archive.js
View
12 lib/jsgi/archive.js
@@ -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);

0 comments on commit 3adeda0

Please sign in to comment.