Skip to content

Commit

Permalink
Fixes data initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
guifromrio committed Dec 17, 2013
1 parent 44b5719 commit f9d62fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions libs/s3-utils.js
Expand Up @@ -69,14 +69,19 @@
return deferred.reject(err);
});
req.on("response", function(res) {
var data;
data = '';
if (res.statusCode === 404) {
console.warn("No object found at " + path + ".");
return deferred.resolve({});
} else if (res.statusCode === 200) {
return res.on('data', function(chunk) {
res.on('data', function(chunk) {
return data += chunk;
});
return res.on('end', function() {
var e, obj;
try {
obj = JSON.parse(chunk);
obj = JSON.parse(data);
return deferred.resolve(obj);
} catch (_error) {
e = _error;
Expand Down
2 changes: 1 addition & 1 deletion src/s3-utils.coffee
Expand Up @@ -48,7 +48,7 @@ exports.downloadObject = (path, client, timeoutMillis = 1000*30) =>
deferred.reject err

req.on "response", (res) =>
data = undefined
data = ''
if res.statusCode is 404
console.warn "No object found at #{path}."
deferred.resolve {}
Expand Down

0 comments on commit f9d62fb

Please sign in to comment.