mirror of
https://github.com/azures04/crafatar.git
synced 2026-05-06 19:10:38 +02:00
fix tests
This commit is contained in:
@@ -2,8 +2,8 @@ var config = {
|
||||
min_size: 1, // < 1 will (obviously) cause crash
|
||||
max_size: 512, // too big values might lead to slow response time or DoS
|
||||
default_size: 160, // size to be used when no size given
|
||||
local_cache_time: 3600, // seconds until we will check if the image changed. should be > 60 to prevent mojang 429 response
|
||||
browser_cache_time: 3600, // seconds until browser will request image again
|
||||
local_cache_time: 30, // seconds until we will check if the image changed. should be > 60 to prevent mojang 429 response
|
||||
browser_cache_time: 30, // seconds until browser will request image again
|
||||
http_timeout: 3000, // ms until connection to mojang is dropped
|
||||
faces_dir: 'skins/faces/', // directory where faces are kept. should have trailing '/'
|
||||
helms_dir: 'skins/helms/', // directory where helms are kept. should have trailing '/'
|
||||
|
||||
@@ -35,11 +35,12 @@ function store_images(uuid, details, callback) {
|
||||
logging.log(uuid + " new hash: " + hash);
|
||||
var facepath = __dirname + '/../' + config.faces_dir + hash + ".png";
|
||||
var helmpath = __dirname + '/../' + config.helms_dir + hash + ".png";
|
||||
// download skin, extract face/helm
|
||||
networking.skin_file(skin_url, facepath, function(err, img) {
|
||||
if (err) {
|
||||
// download skin
|
||||
networking.get_skin(skin_url, function(err, img) {
|
||||
if (err || !img) {
|
||||
callback(err, null);
|
||||
} else {
|
||||
// extract face / helm
|
||||
skins.extract_face(img, facepath, function(err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
@@ -148,7 +149,7 @@ exp.get_skin = function(uuid, callback) {
|
||||
exp.get_image_hash(uuid, function(err, status, hash) {
|
||||
if (hash) {
|
||||
var skinurl = "http://textures.minecraft.net/texture/" + hash;
|
||||
networking.skin_file(skinurl, null, function(err, img) {
|
||||
networking.get_skin(skinurl, null, function(err, img) {
|
||||
if (err) {
|
||||
logging.log("\nerror while downloading skin");
|
||||
callback(err, hash, null);
|
||||
|
||||
@@ -99,15 +99,8 @@ exp.get_skin_url = function(uuid, callback) {
|
||||
};
|
||||
|
||||
// downloads skin file from +url+
|
||||
// stores face image as +facename+
|
||||
// stores helm image as +helmname+
|
||||
// callback contains error
|
||||
exp.skin_file = function(url, facename, callback) {
|
||||
if (facename && fs.existsSync(facename)) {
|
||||
logging.log("Images already exist, not downloading.");
|
||||
callback(null, null);
|
||||
return;
|
||||
}
|
||||
// callback contains error, image
|
||||
exp.get_skin = function(url, callback) {
|
||||
request.get({
|
||||
url: url,
|
||||
encoding: null, // encoding must be null so we get a buffer
|
||||
|
||||
Reference in New Issue
Block a user