raise error on 429 TooManyRequests

this has the effect that we're not caching 'null' as a reponse. see #99
This commit is contained in:
jomo 2015-02-18 23:55:34 +01:00
parent 5b8493df15
commit dc33912ec7
2 changed files with 11 additions and 10 deletions

View File

@ -32,20 +32,20 @@ function store_skin(rid, userId, profile, details, callback) {
logging.log(rid + "skin already exists, not downloading"); logging.log(rid + "skin already exists, not downloading");
callback(null, skin_hash); callback(null, skin_hash);
} else { } else {
networking.get_from(rid, url, function(img, response, err) { networking.get_from(rid, url, function(img, response, err1) {
if (err || !img) { if (err1 || !img) {
callback(err, null); callback(err1, null);
} else { } else {
skins.extract_face(img, facepath, function(err) { skins.extract_face(img, facepath, function(err2) {
if (err) { if (err2) {
logging.error(rid + err.stack); logging.error(rid + err2.stack);
callback(err, null); callback(err2, null);
} else { } else {
logging.log(rid + "face extracted"); 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.log(rid + "helm extracted");
logging.debug(rid + helmpath); logging.debug(rid + helmpath);
callback(err, skin_hash); callback(err3, skin_hash);
}); });
} }
}); });

View File

@ -69,7 +69,8 @@ exp.get_from_options = function(rid, url, options, callback) {
callback(null, response, null); callback(null, response, null);
} else if (code === 429) { } else if (code === 429) {
// Too Many Requests exception - 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 { } else {
logging.error(rid + " Unknown reply:"); logging.error(rid + " Unknown reply:");
logging.error(rid + JSON.stringify(response)); logging.error(rid + JSON.stringify(response));