From b4688d140fca083151da0551ef94cbf7c603dbd2 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Thu, 20 Jun 2013 20:54:50 +0400 Subject: [PATCH] caching tarballs --- lib/storage.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/storage.js b/lib/storage.js index fe6ba0313..7afb26a8a 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -113,15 +113,22 @@ Storage.prototype.get_tarball = function(name, filename, callback) { }, self.config); } + var savestream = self.local.add_tarball(name, filename); + savestream.on('error', function(err) { + stream.emit('error', err); + }); + var rstream2 = uplink.get_url(file.url); rstream2.on('error', function(err) { stream.emit('error', err); }); rstream2.on('data', function(data) { stream.write(data); + savestream.write(data); }); rstream2.on('end', function() { stream.end(); + savestream.end(); }); }); });