|
@@ -210,12 +210,7 @@ exp.id_valid = function(userId) {
|
|
|
|
|
|
// decides whether to get a +type+ image for +userId+ from disk or to download it
|
|
// decides whether to get a +type+ image for +userId+ from disk or to download it
|
|
// callback: error, status, hash
|
|
// callback: error, status, hash
|
|
-// the status gives information about how the image was received
|
|
|
|
-// -1: "error"
|
|
|
|
-// 0: "none" - cached as null
|
|
|
|
-// 1: "cached" - found on disk
|
|
|
|
-// 2: "downloaded" - profile downloaded, skin downloaded from mojang servers
|
|
|
|
-// 3: "checked" - profile re-downloaded (was too old), but it has either not changed or has no skin
|
|
|
|
|
|
+// for status, see response.js
|
|
exp.get_image_hash = function(rid, userId, type, callback) {
|
|
exp.get_image_hash = function(rid, userId, type, callback) {
|
|
cache.get_details(userId, function(err, cache_details) {
|
|
cache.get_details(userId, function(err, cache_details) {
|
|
var cached_hash = null;
|
|
var cached_hash = null;
|
|
@@ -357,11 +352,11 @@ exp.get_render = function(rid, userId, scale, helm, body, callback) {
|
|
};
|
|
};
|
|
|
|
|
|
// handles requests for +userId+ capes
|
|
// handles requests for +userId+ capes
|
|
-// callback: error, cape hash, image buffer
|
|
|
|
|
|
+// callback: error, cape hash, status, image buffer
|
|
exp.get_cape = function(rid, userId, callback) {
|
|
exp.get_cape = function(rid, userId, callback) {
|
|
exp.get_image_hash(rid, userId, "cape", function(err, status, cape_hash) {
|
|
exp.get_image_hash(rid, userId, "cape", function(err, status, cape_hash) {
|
|
if (!cape_hash) {
|
|
if (!cape_hash) {
|
|
- callback(err, null, null);
|
|
|
|
|
|
+ callback(err, null, null, null);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var capepath = path.join(__dirname, "..", config.capes_dir, cape_hash + ".png");
|
|
var capepath = path.join(__dirname, "..", config.capes_dir, cape_hash + ".png");
|
|
@@ -369,14 +364,14 @@ exp.get_cape = function(rid, userId, callback) {
|
|
if (exists) {
|
|
if (exists) {
|
|
logging.log(rid, "cape already exists, not downloading");
|
|
logging.log(rid, "cape already exists, not downloading");
|
|
skins.open_skin(rid, capepath, function(skin_err, img) {
|
|
skins.open_skin(rid, capepath, function(skin_err, img) {
|
|
- callback(skin_err, cape_hash, img);
|
|
|
|
|
|
+ callback(skin_err || err, cape_hash, status, img);
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|
|
networking.save_texture(rid, cape_hash, capepath, function(net_err, response, img) {
|
|
networking.save_texture(rid, cape_hash, capepath, function(net_err, response, img) {
|
|
if (response && response.statusCode === 404) {
|
|
if (response && response.statusCode === 404) {
|
|
- callback(net_err, cape_hash, null);
|
|
|
|
|
|
+ callback(net_err, cape_hash, status, null);
|
|
} else {
|
|
} else {
|
|
- callback(net_err, cape_hash, img);
|
|
|
|
|
|
+ callback(net_err, cape_hash, status, img);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|