From 3fdd942c0f1c507b86bb530adf051c9dac64aeef Mon Sep 17 00:00:00 2001 From: jomo Date: Sat, 14 Feb 2015 20:26:09 +0100 Subject: [PATCH 1/4] cache non-existing UUIDs, fixes #93 --- modules/helpers.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/helpers.js b/modules/helpers.js index f9a9028..dc6a82b 100644 --- a/modules/helpers.js +++ b/modules/helpers.js @@ -146,7 +146,15 @@ function store_images(rid, userId, details, type, callback) { currently_running.push(new_hash); networking.get_profile(rid, (is_uuid ? userId : null), function(err, profile) { if (err || (is_uuid && !profile)) { - callback_for(userId, type, err, null); + if (!err && !profile) { + cache.save_hash(rid, userId, null, null, function(cache_err) { + // we have no profile, so we have neither skin nor cape + callback_for(userId, "skin", cache_err, null); + callback_for(userId, "cape", cache_err, null); + }); + } else { + callback_for(userId, type, err, null); + } } else { store_skin(rid, userId, profile, details, function(err, skin_hash) { cache.save_hash(rid, userId, skin_hash, null, function(cache_err) { From 2a172cc6f95717713edc0ac6a1601ef2ee613fd6 Mon Sep 17 00:00:00 2001 From: jomo Date: Sat, 14 Feb 2015 20:50:45 +0100 Subject: [PATCH 2/4] switch from node 0.12 to iojs 1.2, closes #89 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 27cd8a1..505aa48 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "test": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" }, "engines": { - "node": "0.12.x" + "iojs": "1.2.x" }, "dependencies": { "canvas": "crafatar/node-canvas", From 8750b863a890c071aaa29cdb2683346ea585fb00 Mon Sep 17 00:00:00 2001 From: jomo Date: Sat, 14 Feb 2015 21:23:56 +0100 Subject: [PATCH 3/4] contributing: add tests for fixed issues --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 21f0014..81bb0b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,6 +17,7 @@ 0. If you add new functions, **add documentation** (comment above) * Wrap function arguments in `+` signs (e.g. `the +type+ is used for…`) 0. If you add new functions, **add tests** (test/test.js) +0. If you fixed an issue, **add a test** that would catch this issue 0. Run **tests** (`npm test`) 0. Make sure as much of your code as possible is **covered by tests** 0. Double check that your pull request is **awesome** :) \ No newline at end of file From de5bad8702ec622d70fb26b780892880e96d203c Mon Sep 17 00:00:00 2001 From: jomo Date: Sat, 14 Feb 2015 21:48:47 +0100 Subject: [PATCH 4/4] code cleanup --- bin/www.js | 4 ++-- modules/renders.js | 7 +++---- routes/capes.js | 3 ++- routes/renders.js | 3 ++- server.js | 1 - 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/www.js b/bin/www.js index 323b4ef..ffefdf9 100644 --- a/bin/www.js +++ b/bin/www.js @@ -10,8 +10,8 @@ if (cluster.isMaster) { cluster.fork(); } - cluster.on("exit", function (worker, code, signal) { - logging.error("Worker died. Rebooting a new one."); + cluster.on("exit", function (worker) { + logging.error("Worker #" + worker.id + " died. Rebooting a new one."); setTimeout(cluster.fork, 100); }); diff --git a/modules/renders.js b/modules/renders.js index 4f1776e..c5ca3c4 100644 --- a/modules/renders.js +++ b/modules/renders.js @@ -2,7 +2,6 @@ // https://github.com/confuser/serverless-mc-skin-viewer // Permission to use & distribute https://github.com/confuser/serverless-mc-skin-viewer/blob/master/LICENSE -var helpers = require("./helpers"); var logging = require("./logging"); var fs = require("fs"); var Canvas = require("canvas"); @@ -43,7 +42,7 @@ exp.draw_head = function(skin_canvas, model_ctx, scale) { // using the skin from the +model_ctx+ at the +scale+ // parts are labeled as if drawn from the skin's POV exp.draw_body = function(rid, skin_canvas, model_ctx, scale) { - if (skin_canvas.height == 32 * scale) { + if (skin_canvas.height === 32 * scale) { logging.debug(rid + "uses old skin format"); //Left Leg //Left Leg - Front @@ -189,8 +188,8 @@ function scale_image(imageData, context, d_x, d_y, scale) { var width = imageData.width; var height = imageData.height; context.clearRect(0,0,width,height); //Clear the spot where it originated from - for(y=0; y