From dc33912ec740dc539f3d00809853ac88260bef3f Mon Sep 17 00:00:00 2001 From: jomo Date: Wed, 18 Feb 2015 23:55:34 +0100 Subject: [PATCH] raise error on 429 TooManyRequests this has the effect that we're not caching 'null' as a reponse. see #99 --- modules/helpers.js | 18 +++++++++--------- modules/networking.js | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/helpers.js b/modules/helpers.js index 52097f5..14c97b6 100644 --- a/modules/helpers.js +++ b/modules/helpers.js @@ -32,20 +32,20 @@ function store_skin(rid, userId, profile, details, callback) { logging.log(rid + "skin already exists, not downloading"); callback(null, skin_hash); } else { - networking.get_from(rid, url, function(img, response, err) { - if (err || !img) { - callback(err, null); + networking.get_from(rid, url, function(img, response, err1) { + if (err1 || !img) { + callback(err1, null); } else { - skins.extract_face(img, facepath, function(err) { - if (err) { - logging.error(rid + err.stack); - callback(err, null); + skins.extract_face(img, facepath, function(err2) { + if (err2) { + logging.error(rid + err2.stack); + callback(err2, null); } else { logging.log(rid + "face extracted"); - skins.extract_helm(rid, facepath, img, helmpath, function(err) { + skins.extract_helm(rid, facepath, img, helmpath, function(err3) { logging.log(rid + "helm extracted"); logging.debug(rid + helmpath); - callback(err, skin_hash); + callback(err3, skin_hash); }); } }); diff --git a/modules/networking.js b/modules/networking.js index 1ec07e4..f42179b 100644 --- a/modules/networking.js +++ b/modules/networking.js @@ -69,7 +69,8 @@ exp.get_from_options = function(rid, url, options, callback) { callback(null, response, null); } else if (code === 429) { // Too Many Requests exception - code 429 - callback(body || null, response, error); + // cause error so the image will not be cached + callback(body || null, response, (error || "TooManyRequests")); } else { logging.error(rid + " Unknown reply:"); logging.error(rid + JSON.stringify(response));