mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-22 07:51:17 +01:00
prepend uuid to all logs
This commit is contained in:
parent
c90c030904
commit
e437b90b51
@ -37,7 +37,7 @@ function connect_redis() {
|
|||||||
|
|
||||||
// sets the date of the face file belonging to +hash+ to now
|
// sets the date of the face file belonging to +hash+ to now
|
||||||
// the helms file is ignored because we only need 1 file to read/write from
|
// the helms file is ignored because we only need 1 file to read/write from
|
||||||
function update_file_date(hash) {
|
function update_file_date(hash, uuid) {
|
||||||
if (hash) {
|
if (hash) {
|
||||||
var path = config.faces_dir + hash + ".png";
|
var path = config.faces_dir + hash + ".png";
|
||||||
fs.exists(path, function(exists) {
|
fs.exists(path, function(exists) {
|
||||||
@ -45,11 +45,11 @@ function update_file_date(hash) {
|
|||||||
var date = new Date();
|
var date = new Date();
|
||||||
fs.utimes(path, date, date, function(err){
|
fs.utimes(path, date, date, function(err){
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.error(err);
|
logging.error(uuid + " Error: " + err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
logging.error("Tried to update " + path + " date, but it does not exist");
|
logging.error(uuid + " tried to update " + path + " date, but it does not exist");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ exp.update_timestamp = function(uuid, hash) {
|
|||||||
// store uuid in lower case if not null
|
// store uuid in lower case if not null
|
||||||
uuid = uuid && uuid.toLowerCase();
|
uuid = uuid && uuid.toLowerCase();
|
||||||
redis.hmset(uuid, "t", time);
|
redis.hmset(uuid, "t", time);
|
||||||
update_file_date(hash);
|
update_file_date(hash, uuid);
|
||||||
};
|
};
|
||||||
|
|
||||||
// create the key +uuid+, store +hash+ and time
|
// create the key +uuid+, store +hash+ and time
|
||||||
|
|||||||
@ -44,7 +44,7 @@ function store_images(uuid, details, callback) {
|
|||||||
callback(null, hash);
|
callback(null, hash);
|
||||||
} else {
|
} else {
|
||||||
// download skin
|
// download skin
|
||||||
networking.get_skin(skin_url, function(err, img) {
|
networking.get_skin(skin_url, uuid, function(err, img) {
|
||||||
if (err || !img) {
|
if (err || !img) {
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
} else {
|
} else {
|
||||||
@ -54,10 +54,10 @@ function store_images(uuid, details, callback) {
|
|||||||
callback(err);
|
callback(err);
|
||||||
} else {
|
} else {
|
||||||
logging.log(uuid + " face extracted");
|
logging.log(uuid + " face extracted");
|
||||||
logging.debug(facepath);
|
logging.debug(uuid + " " + facepath);
|
||||||
skins.extract_helm(facepath, img, helmpath, function(err) {
|
skins.extract_helm(uuid, facepath, img, helmpath, function(err) {
|
||||||
logging.log(uuid + " helm extracted");
|
logging.log(uuid + " helm extracted");
|
||||||
logging.debug(helmpath);
|
logging.debug(uuid + " " + helmpath);
|
||||||
cache.save_hash(uuid, hash);
|
cache.save_hash(uuid, hash);
|
||||||
callback(err, hash);
|
callback(err, hash);
|
||||||
});
|
});
|
||||||
@ -133,7 +133,6 @@ exp.get_image_hash = function(uuid, callback) {
|
|||||||
// image is the user's face+helm when helm is true, or the face otherwise
|
// image is the user's face+helm when helm is true, or the face otherwise
|
||||||
// for status, see get_image_hash
|
// for status, see get_image_hash
|
||||||
exp.get_avatar = function(uuid, helm, size, callback) {
|
exp.get_avatar = function(uuid, helm, size, callback) {
|
||||||
logging.log("request: " + uuid);
|
|
||||||
exp.get_image_hash(uuid, function(err, status, hash) {
|
exp.get_image_hash(uuid, function(err, status, hash) {
|
||||||
if (hash) {
|
if (hash) {
|
||||||
var facepath = __dirname + "/../" + config.faces_dir + hash + ".png";
|
var facepath = __dirname + "/../" + config.faces_dir + hash + ".png";
|
||||||
@ -165,13 +164,12 @@ exp.get_avatar = function(uuid, helm, size, callback) {
|
|||||||
// handles requests for +uuid+ skins
|
// handles requests for +uuid+ skins
|
||||||
// callback contains error, hash, image buffer
|
// callback contains error, hash, image buffer
|
||||||
exp.get_skin = function(uuid, callback) {
|
exp.get_skin = function(uuid, callback) {
|
||||||
logging.log(uuid + " skin request");
|
|
||||||
exp.get_image_hash(uuid, function(err, status, hash) {
|
exp.get_image_hash(uuid, function(err, status, hash) {
|
||||||
var skinpath = __dirname + "/../" + config.skins_dir + hash + ".png";
|
var skinpath = __dirname + "/../" + config.skins_dir + hash + ".png";
|
||||||
fs.exists(skinpath, function (exists) {
|
fs.exists(skinpath, function (exists) {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
logging.log("skin already exists, not downloading");
|
logging.log(uuid + " skin already exists, not downloading");
|
||||||
skins.open_skin(skinpath, function(err, img) {
|
skins.open_skin(uuid, skinpath, function(err, img) {
|
||||||
callback(err, hash, img);
|
callback(err, hash, img);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -191,7 +189,6 @@ function get_type(helm, body) {
|
|||||||
// handles creations of skin renders
|
// handles creations of skin renders
|
||||||
// callback contanis error, hash, image buffer
|
// callback contanis error, hash, image buffer
|
||||||
exp.get_render = function(uuid, scale, helm, body, callback) {
|
exp.get_render = function(uuid, scale, helm, body, callback) {
|
||||||
logging.log(uuid + " render request");
|
|
||||||
exp.get_skin(uuid, function(err, hash, img) {
|
exp.get_skin(uuid, function(err, hash, img) {
|
||||||
if (!hash) {
|
if (!hash) {
|
||||||
callback(err, -1, hash, null);
|
callback(err, -1, hash, null);
|
||||||
@ -200,7 +197,7 @@ exp.get_render = function(uuid, scale, helm, body, callback) {
|
|||||||
var renderpath = __dirname + "/../" + config.renders_dir + hash + "-" + scale + "-" + get_type(helm, body) + ".png";
|
var renderpath = __dirname + "/../" + config.renders_dir + hash + "-" + scale + "-" + get_type(helm, body) + ".png";
|
||||||
fs.exists(renderpath, function (exists) {
|
fs.exists(renderpath, function (exists) {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
renders.open_render(renderpath, function(err, img) {
|
renders.open_render(uuid, renderpath, function(err, img) {
|
||||||
callback(err, 1, hash, img);
|
callback(err, 1, hash, img);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -217,7 +214,7 @@ exp.get_render = function(uuid, scale, helm, body, callback) {
|
|||||||
} else {
|
} else {
|
||||||
fs.writeFile(renderpath, img, "binary", function(err){
|
fs.writeFile(renderpath, img, "binary", function(err){
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.log(err);
|
logging.log(uuid + " error: " + err);
|
||||||
}
|
}
|
||||||
callback(null, 2, hash, img);
|
callback(null, 2, hash, img);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -47,11 +47,11 @@ var get_username_url = function(name, callback) {
|
|||||||
} else if (response.statusCode == 429) {
|
} else if (response.statusCode == 429) {
|
||||||
// Too Many Requests
|
// Too Many Requests
|
||||||
// Never got this, seems like skins aren't limited
|
// Never got this, seems like skins aren't limited
|
||||||
logging.warn(body || "Too many requests");
|
logging.warn(name + body || "Too many requests");
|
||||||
callback(null, null);
|
callback(null, null);
|
||||||
} else {
|
} else {
|
||||||
logging.error(name + " Unknown error:");
|
logging.error(name + " Unknown error:");
|
||||||
logging.error(response);
|
logging.error(name + " " + response);
|
||||||
callback(body || "Unknown error", null);
|
callback(body || "Unknown error", null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -82,7 +82,7 @@ var get_uuid_url = function(uuid, callback) {
|
|||||||
callback(body || "Too many requests", null);
|
callback(body || "Too many requests", null);
|
||||||
} else {
|
} else {
|
||||||
logging.error(uuid + " Unknown error:");
|
logging.error(uuid + " Unknown error:");
|
||||||
logging.error(response);
|
logging.error(uuid + " " + response);
|
||||||
callback(body || "Unknown error", null);
|
callback(body || "Unknown error", null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -106,7 +106,7 @@ exp.get_skin_url = function(uuid, callback) {
|
|||||||
|
|
||||||
// downloads skin file from +url+
|
// downloads skin file from +url+
|
||||||
// callback contains error, image
|
// callback contains error, image
|
||||||
exp.get_skin = function(url, callback) {
|
exp.get_skin = function(url, uuid, callback) {
|
||||||
request.get({
|
request.get({
|
||||||
url: url,
|
url: url,
|
||||||
headers: {
|
headers: {
|
||||||
@ -117,23 +117,23 @@ exp.get_skin = function(url, callback) {
|
|||||||
}, function (error, response, body) {
|
}, function (error, response, body) {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
// skin downloaded successfully
|
// skin downloaded successfully
|
||||||
logging.log("downloaded skin");
|
logging.log(uuid + " downloaded skin");
|
||||||
logging.debug(url);
|
logging.debug(uuid + " " + url);
|
||||||
callback(null, body);
|
callback(null, body);
|
||||||
} else {
|
} else {
|
||||||
if (error) {
|
if (error) {
|
||||||
logging.error("Error downloading '" + url + "': " + error);
|
logging.error(uuid + " error downloading '" + url + "': " + error);
|
||||||
} else if (response.statusCode == 404) {
|
} else if (response.statusCode == 404) {
|
||||||
logging.warn("texture not found (404): " + url);
|
logging.warn(uuid + " texture not found (404): " + url);
|
||||||
} 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
|
||||||
logging.warn("too many requests for " + url);
|
logging.warn(uuid + " too many requests for " + url);
|
||||||
logging.warn(body);
|
logging.warn(uuid + " " + body);
|
||||||
} else {
|
} else {
|
||||||
logging.error("unknown error for " + url);
|
logging.error(uuid + " unknown error for " + url);
|
||||||
logging.error(response);
|
logging.error(uuid + " " + response);
|
||||||
logging.error(body);
|
logging.error(uuid + " " + body);
|
||||||
error = "unknown error"; // Error needs to be set, otherwise null in callback
|
error = "unknown error"; // Error needs to be set, otherwise null in callback
|
||||||
}
|
}
|
||||||
callback(error, null);
|
callback(error, null);
|
||||||
@ -144,14 +144,14 @@ exp.get_skin = function(url, callback) {
|
|||||||
exp.save_skin = function(uuid, hash, outpath, callback) {
|
exp.save_skin = function(uuid, hash, outpath, callback) {
|
||||||
if (hash) {
|
if (hash) {
|
||||||
var skinurl = "http://textures.minecraft.net/texture/" + hash;
|
var skinurl = "http://textures.minecraft.net/texture/" + hash;
|
||||||
exp.get_skin(skinurl, function(err, img) {
|
exp.get_skin(skinurl, uuid, function(err, img) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.error("error while downloading skin");
|
logging.error(uuid + " error while downloading skin");
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
} else {
|
} else {
|
||||||
fs.writeFile(outpath, img, "binary", function(err){
|
fs.writeFile(outpath, img, "binary", function(err){
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.log(err);
|
logging.log(uuid + " error: " + err);
|
||||||
}
|
}
|
||||||
callback(null, img);
|
callback(null, img);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -42,9 +42,9 @@ exp.draw_head = function(skin_canvas, model_ctx, scale) {
|
|||||||
// draws the body on to the +skin_canvas+
|
// draws the body on to the +skin_canvas+
|
||||||
// using the skin from the +model_ctx+ at the +scale+
|
// using the skin from the +model_ctx+ at the +scale+
|
||||||
// parts are labeled as if drawn from the skin's POV
|
// parts are labeled as if drawn from the skin's POV
|
||||||
exp.draw_body = function(skin_canvas, model_ctx, scale) {
|
exp.draw_body = function(uuid, skin_canvas, model_ctx, scale) {
|
||||||
if (skin_canvas.height == 32 * scale) {
|
if (skin_canvas.height == 32 * scale) {
|
||||||
logging.log("old skin");
|
logging.log(uuid + " old skin");
|
||||||
//Left Leg
|
//Left Leg
|
||||||
//Left Leg - Front
|
//Left Leg - Front
|
||||||
model_ctx.setTransform(1,-0.5,0,1.2,0,0);
|
model_ctx.setTransform(1,-0.5,0,1.2,0,0);
|
||||||
@ -85,7 +85,7 @@ exp.draw_body = function(skin_canvas, model_ctx, scale) {
|
|||||||
model_ctx.scale(-1,1);
|
model_ctx.scale(-1,1);
|
||||||
model_ctx.drawImage(skin_canvas, 44*scale, 16*scale, 4*scale, 4*scale, -16*scale, 16*scale, 4*scale, 4*scale);
|
model_ctx.drawImage(skin_canvas, 44*scale, 16*scale, 4*scale, 4*scale, -16*scale, 16*scale, 4*scale, 4*scale);
|
||||||
} else {
|
} else {
|
||||||
logging.log("new skin");
|
logging.log(uuid + " new skin");
|
||||||
//Left Leg
|
//Left Leg
|
||||||
//Left Leg - Front
|
//Left Leg - Front
|
||||||
model_ctx.setTransform(1,-0.5,0,1.2,0,0);
|
model_ctx.setTransform(1,-0.5,0,1.2,0,0);
|
||||||
@ -134,7 +134,7 @@ exp.draw_model = function(uuid, img, scale, helm, body, callback) {
|
|||||||
var image = new Image();
|
var image = new Image();
|
||||||
|
|
||||||
image.onerror = function(err) {
|
image.onerror = function(err) {
|
||||||
logging.error("render error: " + err);
|
logging.error(uuid + " render error: " + err);
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -151,19 +151,19 @@ exp.draw_model = function(uuid, img, scale, helm, body, callback) {
|
|||||||
//Scale it
|
//Scale it
|
||||||
scale_image(skin_ctx.getImageData(0,0,64,original_height), skin_ctx, 0, 0, scale);
|
scale_image(skin_ctx.getImageData(0,0,64,original_height), skin_ctx, 0, 0, scale);
|
||||||
if (body) {
|
if (body) {
|
||||||
logging.log("drawing body");
|
logging.log(uuid + " drawing body");
|
||||||
exp.draw_body(skin_canvas, model_ctx, scale);
|
exp.draw_body(uuid, skin_canvas, model_ctx, scale);
|
||||||
}
|
}
|
||||||
logging.log("drawing head");
|
logging.log(uuid + " drawing head");
|
||||||
exp.draw_head(skin_canvas, model_ctx, scale);
|
exp.draw_head(skin_canvas, model_ctx, scale);
|
||||||
if (helm) {
|
if (helm) {
|
||||||
logging.log("drawing helmet");
|
logging.log(uuid + " drawing helmet");
|
||||||
exp.draw_helmet(skin_canvas, model_ctx, scale);
|
exp.draw_helmet(skin_canvas, model_ctx, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
model_canvas.toBuffer(function(err, buf){
|
model_canvas.toBuffer(function(err, buf){
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.log("error creating buffer: " + err);
|
logging.log(uuid + " error creating buffer: " + err);
|
||||||
}
|
}
|
||||||
callback(err, buf);
|
callback(err, buf);
|
||||||
});
|
});
|
||||||
@ -174,10 +174,10 @@ exp.draw_model = function(uuid, img, scale, helm, body, callback) {
|
|||||||
|
|
||||||
// helper method to open a render from +renderpath+
|
// helper method to open a render from +renderpath+
|
||||||
// callback contains error, image buffer
|
// callback contains error, image buffer
|
||||||
exp.open_render = function(renderpath, callback) {
|
exp.open_render = function(uuid, renderpath, callback) {
|
||||||
fs.readFile(renderpath, function (err, buf) {
|
fs.readFile(renderpath, function (err, buf) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.error("error while opening skin file: " + err);
|
logging.error(uuid + " error while opening skin file: " + err);
|
||||||
}
|
}
|
||||||
callback(err, buf);
|
callback(err, buf);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -29,7 +29,7 @@ exp.extract_face = function(buffer, outname, callback) {
|
|||||||
// +facefile+ is the filename of an image produced by extract_face
|
// +facefile+ is the filename of an image produced by extract_face
|
||||||
// result is saved to a file called +outname+
|
// result is saved to a file called +outname+
|
||||||
// +callback+ contains error
|
// +callback+ contains error
|
||||||
exp.extract_helm = function(facefile, buffer, outname, callback) {
|
exp.extract_helm = function(uuid, facefile, buffer, outname, callback) {
|
||||||
lwip.open(buffer, "png", function(err, skin_img) {
|
lwip.open(buffer, "png", function(err, skin_img) {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
@ -53,7 +53,7 @@ exp.extract_helm = function(facefile, buffer, outname, callback) {
|
|||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
logging.log("Helm image is the same as face image, not storing!");
|
logging.log(uuid + " helm image is the same as face image, not storing!");
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -95,10 +95,10 @@ exp.default_skin = function(uuid) {
|
|||||||
|
|
||||||
// helper method for opening a skin file from +skinpath+
|
// helper method for opening a skin file from +skinpath+
|
||||||
// callback contains error, image buffer
|
// callback contains error, image buffer
|
||||||
exp.open_skin = function(skinpath, callback) {
|
exp.open_skin = function(uuid, skinpath, callback) {
|
||||||
fs.readFile(skinpath, function (err, buf) {
|
fs.readFile(skinpath, function (err, buf) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.error("error while opening skin file: " + err);
|
logging.error(uuid + " error while opening skin file: " + err);
|
||||||
}
|
}
|
||||||
callback(err, buf);
|
callback(err, buf);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -50,7 +50,6 @@ module.exports = function(req, res) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
logging.error(uuid + " " + err);
|
logging.error(uuid + " " + err);
|
||||||
if (err.code == "ENOENT") {
|
if (err.code == "ENOENT") {
|
||||||
logging.warn("Deleting " + uuid + " from cache!");
|
|
||||||
cache.remove_hash(uuid);
|
cache.remove_hash(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,16 +62,15 @@ module.exports = function(req, res) {
|
|||||||
} else if (err) {
|
} else if (err) {
|
||||||
http_status = 503;
|
http_status = 503;
|
||||||
}
|
}
|
||||||
logging.debug("Etag: " + req.headers["if-none-match"]);
|
logging.debug(uuid + " etag: " + req.headers["if-none-match"]);
|
||||||
logging.debug("matches: " + matches);
|
logging.debug(uuid + " matches: " + matches);
|
||||||
sendimage(http_status, status, image, uuid);
|
sendimage(http_status, status, image, uuid);
|
||||||
} else {
|
} else {
|
||||||
handle_default(404, status, uuid);
|
handle_default(404, status, uuid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
logging.error(uuid + " error:");
|
logging.error(uuid + " error: " + e);
|
||||||
logging.error(e);
|
|
||||||
handle_default(500, status, uuid);
|
handle_default(500, status, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,17 +73,16 @@ module.exports = function(req, res) {
|
|||||||
} else if (err) {
|
} else if (err) {
|
||||||
http_status = 503;
|
http_status = 503;
|
||||||
}
|
}
|
||||||
logging.log("matches: " + matches);
|
logging.debug(uuid + " etag: " + req.headers["if-none-match"]);
|
||||||
logging.log("Etag: " + req.headers["if-none-match"]);
|
logging.debug(uuid + " matches: " + matches);
|
||||||
sendimage(http_status, status, image, uuid);
|
sendimage(http_status, status, image, uuid);
|
||||||
} else {
|
} else {
|
||||||
logging.log("image not found, using default.");
|
logging.log(uuid + " image not found, using default.");
|
||||||
handle_default(404, status, uuid);
|
handle_default(404, status, uuid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
logging.error(uuid + " error:");
|
logging.error(uuid + " error: " + e);
|
||||||
logging.error(e);
|
|
||||||
handle_default(500, status, uuid);
|
handle_default(500, status, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,12 +105,12 @@ module.exports = function(req, res) {
|
|||||||
fs.readFile("public/images/" + def + "_skin.png", function (err, buf) {
|
fs.readFile("public/images/" + def + "_skin.png", function (err, buf) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// errored while loading the default image, continuing with null image
|
// errored while loading the default image, continuing with null image
|
||||||
logging.error("error loading default render image: " + err);
|
logging.error(uuid + "error loading default render image: " + err);
|
||||||
}
|
}
|
||||||
// we render the default skins, but not custom images
|
// we render the default skins, but not custom images
|
||||||
renders.draw_model(uuid, buf, scale, helm, body, function(err, def_img) {
|
renders.draw_model(uuid, buf, scale, helm, body, function(err, def_img) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.log("error while rendering default image: " + err);
|
logging.log(uuid + "error while rendering default image: " + err);
|
||||||
}
|
}
|
||||||
sendimage(http_status, img_status, def_img, uuid);
|
sendimage(http_status, img_status, def_img, uuid);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -39,16 +39,15 @@ module.exports = function(req, res) {
|
|||||||
} else if (err) {
|
} else if (err) {
|
||||||
http_status = 503;
|
http_status = 503;
|
||||||
}
|
}
|
||||||
logging.debug("Etag: " + req.headers["if-none-match"]);
|
logging.debug(uuid + " etag: " + req.headers["if-none-match"]);
|
||||||
logging.debug("matches: " + matches);
|
logging.debug(uuid + " matches: " + matches);
|
||||||
sendimage(http_status, image, uuid);
|
sendimage(http_status, image, uuid);
|
||||||
} else {
|
} else {
|
||||||
handle_default(404, uuid);
|
handle_default(404, uuid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
logging.error(uuid + " error:");
|
logging.error(uuid + " error: " + e);
|
||||||
logging.error(e);
|
|
||||||
handle_default(500, uuid);
|
handle_default(500, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -135,7 +135,7 @@ describe("Crafatar", function() {
|
|||||||
it("should time out on skin download", function(done) {
|
it("should time out on skin download", function(done) {
|
||||||
var original_timeout = config.http_timeout;
|
var original_timeout = config.http_timeout;
|
||||||
config.http_timeout = 1;
|
config.http_timeout = 1;
|
||||||
networking.get_skin("http://textures.minecraft.net/texture/477be35554684c28bdeee4cf11c591d3c88afb77e0b98da893fd7bc318c65184", function(err, img) {
|
networking.get_skin("http://textures.minecraft.net/texture/477be35554684c28bdeee4cf11c591d3c88afb77e0b98da893fd7bc318c65184", uuid, function(err, img) {
|
||||||
assert.strictEqual(err.code, "ETIMEDOUT");
|
assert.strictEqual(err.code, "ETIMEDOUT");
|
||||||
config.http_timeout = original_timeout;
|
config.http_timeout = original_timeout;
|
||||||
done();
|
done();
|
||||||
@ -143,7 +143,7 @@ describe("Crafatar", function() {
|
|||||||
});
|
});
|
||||||
it("should not find the skin", function(done) {
|
it("should not find the skin", function(done) {
|
||||||
assert.doesNotThrow(function() {
|
assert.doesNotThrow(function() {
|
||||||
networking.get_skin("http://textures.minecraft.net/texture/this-does-not-exist", function(err, img) {
|
networking.get_skin("http://textures.minecraft.net/texture/this-does-not-exist", uuid, function(err, img) {
|
||||||
assert.strictEqual(err, null); // no error here, but it shouldn't throw exceptions
|
assert.strictEqual(err, null); // no error here, but it shouldn't throw exceptions
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user