Fix an issue with errors being null in skin_file callback

This commit is contained in:
Jake 2014-11-20 22:10:07 -06:00
parent 8d73f50dd4
commit c717f0f293
2 changed files with 7 additions and 1 deletions

View File

@ -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);

View File

@ -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);
}