mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
Move extraction logic
This commit is contained in:
parent
2cc7b455af
commit
caf7c731da
@ -36,12 +36,22 @@ function store_images(uuid, details, callback) {
|
||||
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, helmpath, function(err) {
|
||||
networking.skin_file(skin_url, facepath, helmpath, function(err, img) {
|
||||
if (err) {
|
||||
callback(err, null);
|
||||
} else {
|
||||
cache.save_hash(uuid, hash);
|
||||
callback(null, hash);
|
||||
skins.extract_face(img, facepath, function(err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
logging.log(facepath + " face extracted");
|
||||
skins.extract_helm(facepath, img, helmpath, function(err) {
|
||||
logging.log(helmpath + " helm extracted.");
|
||||
cache.save_hash(uuid, hash);
|
||||
callback(err, hash);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -116,17 +116,7 @@ exp.skin_file = function(url, facename, helmname, callback) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
// skin downloaded successfully
|
||||
logging.log(url + " skin downloaded");
|
||||
skins.extract_face(body, facename, function(err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
logging.log(facename + " face extracted");
|
||||
skins.extract_helm(facename, body, helmname, function(err) {
|
||||
logging.log(helmname + " helm extracted.");
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
callback(error, body);
|
||||
} else {
|
||||
if (error) {
|
||||
logging.error("Error downloading '" + url + "': " + error);
|
||||
@ -143,7 +133,7 @@ exp.skin_file = function(url, facename, helmname, callback) {
|
||||
logging.error(body);
|
||||
error = "unknown error"; // Error needs to be set, otherwise null in callback
|
||||
}
|
||||
callback(error);
|
||||
callback(error, null);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user