mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
naming things is hard n°2
This commit is contained in:
parent
aaedc2f3aa
commit
6cb4a46ac7
@ -192,14 +192,14 @@ exp.id_valid = function(userId) {
|
|||||||
// 3: "checked" - profile re-downloaded (was too old), but it has either not changed or has no skin
|
// 3: "checked" - profile re-downloaded (was too old), but it has either not changed or has no skin
|
||||||
exp.get_image_hash = function(rid, userId, type, callback) {
|
exp.get_image_hash = function(rid, userId, type, callback) {
|
||||||
cache.get_details(userId, function(err, details) {
|
cache.get_details(userId, function(err, details) {
|
||||||
var hash = details !== null ? (type === "skin" ? details.skin : details.cape) : null;
|
var cached_hash = details !== null ? (type === "skin" ? details.skin : details.cape) : null;
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err, -1, null);
|
callback(err, -1, null);
|
||||||
} else {
|
} else {
|
||||||
if (details && details.time + config.local_cache_time * 1000 >= new Date().getTime()) {
|
if (details && details.time + config.local_cache_time * 1000 >= new Date().getTime()) {
|
||||||
// use cached image
|
// use cached image
|
||||||
logging.log(rid + "userId cached & recently updated");
|
logging.log(rid + "userId cached & recently updated");
|
||||||
callback(null, (hash ? 1 : 0), hash);
|
callback(null, (cached_hash ? 1 : 0), cached_hash);
|
||||||
} else {
|
} else {
|
||||||
// download image
|
// download image
|
||||||
if (details) {
|
if (details) {
|
||||||
@ -209,12 +209,12 @@ exp.get_image_hash = function(rid, userId, type, callback) {
|
|||||||
}
|
}
|
||||||
store_images(rid, userId, details, type, function(err, new_hash) {
|
store_images(rid, userId, details, type, function(err, new_hash) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// we might have a hash although an error occured
|
// we might have a cached hash although an error occured
|
||||||
// (e.g. Mojang servers not reachable, using outdated hash)
|
// (e.g. Mojang servers not reachable, using outdated hash)
|
||||||
callback(err, -1, details && hash);
|
callback(err, -1, details && cached_hash);
|
||||||
} else {
|
} else {
|
||||||
var status = details && (hash === new_hash) ? 3 : 2;
|
var status = details && (cached_hash === new_hash) ? 3 : 2;
|
||||||
logging.debug(rid + "old hash: " + (details && hash));
|
logging.debug(rid + "cached hash: " + (details && cached_hash));
|
||||||
logging.log(rid + "new hash: " + new_hash);
|
logging.log(rid + "new hash: " + new_hash);
|
||||||
callback(null, status, new_hash);
|
callback(null, status, new_hash);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user