diff --git a/modules/helpers.js b/modules/helpers.js index b2df3dc..329b73a 100644 --- a/modules/helpers.js +++ b/modules/helpers.js @@ -4,7 +4,7 @@ var cache = require('./cache'); var skins = require('./skins'); var valid_uuid = /^[0-9a-f]{32}$/; -var hash_pattern = /[A-za-z0-9_-]{1,16}$|((?:[A-za-z][A-za-z]*[0-9]+[A-za-z0-9]*))/; +var hash_pattern = /([^\/]+)(?=\.\w{0,16}$)|((?:[a-z][a-z]*[0-9]+[a-z0-9]*))/; function get_hash(url) { return hash_pattern.exec(url)[0].toLowerCase(); @@ -48,6 +48,9 @@ function store_images(uuid, details, callback) { // download skin, extract face/helm networking.skin_file(skinurl, facepath, helmpath, function(err) { if (err) { + if (uuid.length <= 16) { + cache.save_hash(uuid, null); + } callback(err, null); } else { cache.save_hash(uuid, hash); diff --git a/modules/networking.js b/modules/networking.js index dd35b32..2ea5c74 100644 --- a/modules/networking.js +++ b/modules/networking.js @@ -70,15 +70,18 @@ exp.skin_file = function(url, facename, helmname, callback) { console.error("Error downloading '" + url + "': " + error); } else if (response.statusCode == 404) { console.warn(url + " texture not found"); + error = "texture not found" // Setting error } else if (response.statusCode == 429) { // Too Many Requests // Never got this, seems like textures aren't limited + error = "too many requests" // Error needs to be set, otherwise null in callback console.warn(url + " too many requests"); console.warn(body); } else { console.error(url + " unknown error:"); console.error(response); console.error(body); + error = "unknown error" // Setting error } callback(error); }