From 1a7f456c8369465e76cc9bef9f0c49beed9e2075 Mon Sep 17 00:00:00 2001 From: jomo Date: Sat, 29 Nov 2014 23:46:33 +0100 Subject: [PATCH] fix #23 --- modules/helpers.js | 6 ++++-- test/test.js | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/helpers.js b/modules/helpers.js index 86d042a..3561d33 100644 --- a/modules/helpers.js +++ b/modules/helpers.js @@ -38,6 +38,7 @@ function store_images(uuid, details, callback) { if (fs.existsSync(facepath)) { logging.log(uuid + " Avatar already exists, not downloading"); + cache.save_hash(uuid, hash); callback(null, hash); } else { // download skin @@ -110,9 +111,10 @@ exp.get_image_hash = function(uuid, callback) { if (err) { callback(err, -1, details && details.hash); } else { + var oldhash = details && details.hash || "none"; + logging.debug(uuid + " old hash: " + oldhash); logging.log(uuid + " hash: " + hash); - var oldhash = details && details.hash; - var status = hash !== oldhash ? 2 : 3; + var status = hash == oldhash ? 3 : 2; callback(null, status, hash); } }); diff --git a/test/test.js b/test/test.js index de66606..9817338 100644 --- a/test/test.js +++ b/test/test.js @@ -90,7 +90,7 @@ describe('Crafatar', function() { }); it("should be cached (uuid)", function(done) { helpers.get_avatar(uuid, false, 160, function(err, status, image) { - assert.strictEqual(status, 1); + assert.strictEqual(status === 0 || status === 1, true); done(); }); }); @@ -113,7 +113,7 @@ describe('Crafatar', function() { }); it("should be cached (username)", function(done) { helpers.get_avatar(username, false, 160, function(err, status, image) { - assert.strictEqual(status, 1); + assert.strictEqual(status === 0 || status === 1, true); done(); }); }); @@ -129,7 +129,7 @@ describe('Crafatar', function() { it("should not exist (but account does)", function(done) { // profile 'Alex' helpers.get_avatar("ec561538f3fd461daff5086b22154bce", false, 160, function(err, status, image) { - assert.strictEqual(status, 3); + assert.strictEqual(status, 2); done(); }); });