|
@@ -40,8 +40,8 @@ function store_skin(rid, userId, profile, cache_details, callback) {
|
|
|
var facepath = path.join(config.directories.faces, skin_hash + ".png");
|
|
|
var helmpath = path.join(config.directories.helms, skin_hash + ".png");
|
|
|
var skinpath = path.join(config.directories.skins, skin_hash + ".png");
|
|
|
- fs.exists(facepath, function(exists) {
|
|
|
- if (exists) {
|
|
|
+ fs.access(facepath, function(fs_err) {
|
|
|
+ if (!fs_err) {
|
|
|
logging.debug(rid, "skin already exists, not downloading");
|
|
|
callback(null, skin_hash, slim);
|
|
|
} else {
|
|
@@ -93,8 +93,8 @@ function store_cape(rid, userId, profile, cache_details, callback) {
|
|
|
} else {
|
|
|
logging.debug(rid, "new cape hash:", cape_hash);
|
|
|
var capepath = path.join(config.directories.capes, cape_hash + ".png");
|
|
|
- fs.exists(capepath, function(exists) {
|
|
|
- if (exists) {
|
|
|
+ fs.access(capepath, function(fs_err) {
|
|
|
+ if (!fs_err) {
|
|
|
logging.debug(rid, "cape already exists, not downloading");
|
|
|
callback(null, cape_hash);
|
|
|
} else {
|
|
@@ -272,15 +272,16 @@ exp.get_avatar = function(rid, userId, overlay, size, callback) {
|
|
|
var facepath = path.join(config.directories.faces, skin_hash + ".png");
|
|
|
var helmpath = path.join(config.directories.helms, skin_hash + ".png");
|
|
|
var filepath = facepath;
|
|
|
- fs.exists(helmpath, function(exists) {
|
|
|
- if (overlay && exists) {
|
|
|
+ fs.access(helmpath, function(fs_err) {
|
|
|
+ if (overlay && !fs_err) {
|
|
|
filepath = helmpath;
|
|
|
}
|
|
|
skins.resize_img(filepath, size, function(img_err, image) {
|
|
|
if (img_err) {
|
|
|
callback(img_err, -1, null, skin_hash);
|
|
|
} else {
|
|
|
- callback(err, (err ? -1 : status), image, skin_hash);
|
|
|
+ status = err ? -1 : status;
|
|
|
+ callback(err, status, image, skin_hash);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
@@ -297,8 +298,8 @@ exp.get_skin = function(rid, userId, callback) {
|
|
|
exp.get_image_hash(rid, userId, "skin", function(err, status, skin_hash, slim) {
|
|
|
if (skin_hash) {
|
|
|
var skinpath = path.join(config.directories.skins, skin_hash + ".png");
|
|
|
- fs.exists(skinpath, function(exists) {
|
|
|
- if (exists) {
|
|
|
+ fs.access(skinpath, function(fs_err) {
|
|
|
+ if (!fs_err) {
|
|
|
logging.debug(rid, "skin already exists, not downloading");
|
|
|
skins.open_skin(rid, skinpath, function(skin_err, img) {
|
|
|
callback(skin_err || err, skin_hash, status, img, slim);
|
|
@@ -332,8 +333,8 @@ exp.get_render = function(rid, userId, scale, overlay, body, callback) {
|
|
|
return;
|
|
|
}
|
|
|
var renderpath = path.join(config.directories.renders, [skin_hash, scale, get_type(overlay, body), slim ? "s" : "t"].join("-") + ".png");
|
|
|
- fs.exists(renderpath, function(exists) {
|
|
|
- if (exists) {
|
|
|
+ fs.access(renderpath, function(fs_err) {
|
|
|
+ if (!fs_err) {
|
|
|
renders.open_render(rid, renderpath, function(render_err, rendered_img) {
|
|
|
callback(render_err, 1, skin_hash, rendered_img);
|
|
|
});
|
|
@@ -349,8 +350,8 @@ exp.get_render = function(rid, userId, scale, overlay, body, callback) {
|
|
|
} else if (!drawn_img) {
|
|
|
callback(null, 0, skin_hash, null);
|
|
|
} else {
|
|
|
- fs.writeFile(renderpath, drawn_img, "binary", function(fs_err) {
|
|
|
- callback(fs_err, 2, skin_hash, drawn_img);
|
|
|
+ fs.writeFile(renderpath, drawn_img, "binary", function(write_err) {
|
|
|
+ callback(write_err, 2, skin_hash, drawn_img);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -368,8 +369,8 @@ exp.get_cape = function(rid, userId, callback) {
|
|
|
return;
|
|
|
}
|
|
|
var capepath = path.join(config.directories.capes, cape_hash + ".png");
|
|
|
- fs.exists(capepath, function(exists) {
|
|
|
- if (exists) {
|
|
|
+ fs.access(capepath, function(fs_err) {
|
|
|
+ if (!fs_err) {
|
|
|
logging.debug(rid, "cape already exists, not downloading");
|
|
|
skins.open_skin(rid, capepath, function(skin_err, img) {
|
|
|
callback(skin_err || err, cape_hash, status, img);
|