mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
actually store the skin in store_skin, fixes #108; pipe skins & capes through lwip before saving, fixes #121
This commit is contained in:
parent
679e72759a
commit
288657107e
@ -32,6 +32,7 @@ function store_skin(rid, userId, profile, cache_details, callback) {
|
|||||||
logging.log(rid, "new skin hash:", skin_hash);
|
logging.log(rid, "new skin hash:", skin_hash);
|
||||||
var facepath = path.join(__dirname, "..", config.faces_dir, skin_hash + ".png");
|
var facepath = path.join(__dirname, "..", config.faces_dir, skin_hash + ".png");
|
||||||
var helmpath = path.join(__dirname, "..", config.helms_dir, skin_hash + ".png");
|
var helmpath = path.join(__dirname, "..", config.helms_dir, skin_hash + ".png");
|
||||||
|
var skinpath = path.join(__dirname, "..", config.skins_dir, skin_hash + ".png");
|
||||||
fs.exists(facepath, function(exists) {
|
fs.exists(facepath, function(exists) {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
logging.log(rid, "skin already exists, not downloading");
|
logging.log(rid, "skin already exists, not downloading");
|
||||||
@ -40,6 +41,11 @@ function store_skin(rid, userId, profile, cache_details, callback) {
|
|||||||
networking.get_from(rid, url, function(img, response, err1) {
|
networking.get_from(rid, url, function(img, response, err1) {
|
||||||
if (err1 || !img) {
|
if (err1 || !img) {
|
||||||
callback(err1, null);
|
callback(err1, null);
|
||||||
|
} else {
|
||||||
|
skins.save_image(img, skinpath, function(skin_err) {
|
||||||
|
if (skin_err) {
|
||||||
|
logging.error(rid, skin_err);
|
||||||
|
callback(skin_err, null);
|
||||||
} else {
|
} else {
|
||||||
skins.extract_face(img, facepath, function(err2) {
|
skins.extract_face(img, facepath, function(err2) {
|
||||||
if (err2) {
|
if (err2) {
|
||||||
@ -59,6 +65,8 @@ function store_skin(rid, userId, profile, cache_details, callback) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ var http_code = require("http").STATUS_CODES;
|
|||||||
var logging = require("./logging");
|
var logging = require("./logging");
|
||||||
var request = require("request");
|
var request = require("request");
|
||||||
var config = require("./config");
|
var config = require("./config");
|
||||||
var fs = require("fs");
|
var skins = require("./skins");
|
||||||
|
|
||||||
var session_url = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
var session_url = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||||
var skins_url = "https://skins.minecraft.net/MinecraftSkins/";
|
var skins_url = "https://skins.minecraft.net/MinecraftSkins/";
|
||||||
@ -176,11 +176,8 @@ exp.save_texture = function(rid, tex_hash, outpath, callback) {
|
|||||||
logging.error(rid, "error while downloading texture");
|
logging.error(rid, "error while downloading texture");
|
||||||
callback(err, response, null);
|
callback(err, response, null);
|
||||||
} else {
|
} else {
|
||||||
fs.writeFile(outpath, img, "binary", function(fs_err) {
|
skins.save_image(img, outpath, function(img_err) {
|
||||||
if (fs_err) {
|
callback(img_err, response, img);
|
||||||
logging.error(rid, "error:", fs_err.stack);
|
|
||||||
}
|
|
||||||
callback(fs_err, response, img);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -448,7 +448,7 @@ describe("Crafatar", function() {
|
|||||||
"skin with existing username": {
|
"skin with existing username": {
|
||||||
url: "http://localhost:3000/skins/jeb_",
|
url: "http://localhost:3000/skins/jeb_",
|
||||||
etag: '"a846b82963"',
|
etag: '"a846b82963"',
|
||||||
crc32: 110922424
|
crc32: 26500336
|
||||||
},
|
},
|
||||||
"skin with not existing username": {
|
"skin with not existing username": {
|
||||||
url: "http://localhost:3000/skins/0",
|
url: "http://localhost:3000/skins/0",
|
||||||
@ -468,7 +468,7 @@ describe("Crafatar", function() {
|
|||||||
"skin with existing uuid": {
|
"skin with existing uuid": {
|
||||||
url: "http://localhost:3000/skins/853c80ef3c3749fdaa49938b674adae6",
|
url: "http://localhost:3000/skins/853c80ef3c3749fdaa49938b674adae6",
|
||||||
etag: '"a846b82963"',
|
etag: '"a846b82963"',
|
||||||
crc32: 110922424
|
crc32: 26500336
|
||||||
},
|
},
|
||||||
"skin with not existing uuid": {
|
"skin with not existing uuid": {
|
||||||
url: "http://localhost:3000/skins/00000000000000000000000000000000",
|
url: "http://localhost:3000/skins/00000000000000000000000000000000",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user