mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
Fix an issue with errors being null in skin_file callback
This commit is contained in:
parent
8d73f50dd4
commit
c717f0f293
@ -4,7 +4,7 @@ var cache = require('./cache');
|
|||||||
var skins = require('./skins');
|
var skins = require('./skins');
|
||||||
|
|
||||||
var valid_uuid = /^[0-9a-f]{32}$/;
|
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) {
|
function get_hash(url) {
|
||||||
return hash_pattern.exec(url)[0].toLowerCase();
|
return hash_pattern.exec(url)[0].toLowerCase();
|
||||||
@ -48,6 +48,9 @@ function store_images(uuid, details, callback) {
|
|||||||
// download skin, extract face/helm
|
// download skin, extract face/helm
|
||||||
networking.skin_file(skinurl, facepath, helmpath, function(err) {
|
networking.skin_file(skinurl, facepath, helmpath, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
if (uuid.length <= 16) {
|
||||||
|
cache.save_hash(uuid, null);
|
||||||
|
}
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
} else {
|
} else {
|
||||||
cache.save_hash(uuid, hash);
|
cache.save_hash(uuid, hash);
|
||||||
|
|||||||
@ -70,15 +70,18 @@ exp.skin_file = function(url, facename, helmname, callback) {
|
|||||||
console.error("Error downloading '" + url + "': " + error);
|
console.error("Error downloading '" + url + "': " + error);
|
||||||
} else if (response.statusCode == 404) {
|
} else if (response.statusCode == 404) {
|
||||||
console.warn(url + " texture not found");
|
console.warn(url + " texture not found");
|
||||||
|
error = "texture not found" // Setting error
|
||||||
} else if (response.statusCode == 429) {
|
} else if (response.statusCode == 429) {
|
||||||
// Too Many Requests
|
// Too Many Requests
|
||||||
// Never got this, seems like textures aren't limited
|
// 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(url + " too many requests");
|
||||||
console.warn(body);
|
console.warn(body);
|
||||||
} else {
|
} else {
|
||||||
console.error(url + " unknown error:");
|
console.error(url + " unknown error:");
|
||||||
console.error(response);
|
console.error(response);
|
||||||
console.error(body);
|
console.error(body);
|
||||||
|
error = "unknown error" // Setting error
|
||||||
}
|
}
|
||||||
callback(error);
|
callback(error);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user