Bladeren bron

raise error on 429 TooManyRequests

this has the effect that we're not caching 'null' as a reponse. see #99
jomo 10 jaren geleden
bovenliggende
commit
dc33912ec7
2 gewijzigde bestanden met toevoegingen van 11 en 10 verwijderingen
  1. 9 9
      modules/helpers.js
  2. 2 1
      modules/networking.js

+ 9 - 9
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);
                     });
                   }
                 });

+ 2 - 1
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));