Fix caching issue

This commit is contained in:
Jake 2014-12-06 00:27:25 -06:00
parent 1c33119e05
commit dbd66f88a5
3 changed files with 11 additions and 6 deletions

View File

@ -16,7 +16,7 @@ function connect_redis() {
}
redis.on("ready", function() {
logging.log("Redis connection established.");
if(process.env.HEROKU) {
if(process.env.HEROKU || true) {
logging.log("Running on heroku, flushing redis");
redis.flushall();
}

View File

@ -174,6 +174,11 @@ exp.get_skin = function(uuid, callback) {
});
};
function get_type(helm, body) {
var text = body ? "body" : "head"
return helm ? text+"helm" : text
}
// handles creations of skin renders
// callback contanis error, hash, image buffer
exp.get_render = function(uuid, scale, helm, body, callback) {
@ -184,9 +189,10 @@ exp.get_render = function(uuid, scale, helm, body, callback) {
callback(err, -1, hash, null);
return;
}
var renderpath = __dirname + "/../" + config.renders_dir + hash + "-" + scale + ".png";
console.log("TYPE: " + get_type(helm, body))
var renderpath = __dirname + "/../" + config.renders_dir + hash + "-" + scale + "-" + "-" + get_type(helm, body) + ".png";
if (fs.existsSync(renderpath)) {
renders.open_render(hash, scale, function(err, img) {
renders.open_render(renderpath, function(err, img) {
callback(err, 1, hash, img);
});
return;

View File

@ -4,7 +4,6 @@
var helpers = require('./helpers');
var logging = require('./logging');
var config = require('./config');
var fs = require('fs');
var exp = {};
@ -120,8 +119,8 @@ exp.draw_model = function(uuid, img, scale, helm, body, callback) {
image.src = img;
}
exp.open_render = function(hash, scale, callback) {
fs.readFile(__dirname + "/../" + config.renders_dir + hash + "-" + scale + ".png", function (err, buf) {
exp.open_render = function(renderpath, callback) {
fs.readFile(renderpath, function (err, buf) {
if (err) {
logging.error("error while opening skin file: " + err);
}