This commit is contained in:
jomo 2014-11-29 23:46:33 +01:00
parent 60387c8c7c
commit 1a7f456c83
2 changed files with 7 additions and 5 deletions

View File

@ -38,6 +38,7 @@ function store_images(uuid, details, callback) {
if (fs.existsSync(facepath)) { if (fs.existsSync(facepath)) {
logging.log(uuid + " Avatar already exists, not downloading"); logging.log(uuid + " Avatar already exists, not downloading");
cache.save_hash(uuid, hash);
callback(null, hash); callback(null, hash);
} else { } else {
// download skin // download skin
@ -110,9 +111,10 @@ exp.get_image_hash = function(uuid, callback) {
if (err) { if (err) {
callback(err, -1, details && details.hash); callback(err, -1, details && details.hash);
} else { } else {
var oldhash = details && details.hash || "none";
logging.debug(uuid + " old hash: " + oldhash);
logging.log(uuid + " hash: " + hash); logging.log(uuid + " hash: " + hash);
var oldhash = details && details.hash; var status = hash == oldhash ? 3 : 2;
var status = hash !== oldhash ? 2 : 3;
callback(null, status, hash); callback(null, status, hash);
} }
}); });

View File

@ -90,7 +90,7 @@ describe('Crafatar', function() {
}); });
it("should be cached (uuid)", function(done) { it("should be cached (uuid)", function(done) {
helpers.get_avatar(uuid, false, 160, function(err, status, image) { helpers.get_avatar(uuid, false, 160, function(err, status, image) {
assert.strictEqual(status, 1); assert.strictEqual(status === 0 || status === 1, true);
done(); done();
}); });
}); });
@ -113,7 +113,7 @@ describe('Crafatar', function() {
}); });
it("should be cached (username)", function(done) { it("should be cached (username)", function(done) {
helpers.get_avatar(username, false, 160, function(err, status, image) { helpers.get_avatar(username, false, 160, function(err, status, image) {
assert.strictEqual(status, 1); assert.strictEqual(status === 0 || status === 1, true);
done(); done();
}); });
}); });
@ -129,7 +129,7 @@ describe('Crafatar', function() {
it("should not exist (but account does)", function(done) { it("should not exist (but account does)", function(done) {
// profile 'Alex' // profile 'Alex'
helpers.get_avatar("ec561538f3fd461daff5086b22154bce", false, 160, function(err, status, image) { helpers.get_avatar("ec561538f3fd461daff5086b22154bce", false, 160, function(err, status, image) {
assert.strictEqual(status, 3); assert.strictEqual(status, 2);
done(); done();
}); });
}); });