From a928952dc4289626a4348d3e6cb0bad34b4cf025 Mon Sep 17 00:00:00 2001 From: jomo Date: Thu, 20 Aug 2015 01:52:01 +0200 Subject: [PATCH] don't force image directories to be relative --- lib/cache.js | 2 +- lib/cleaner.js | 10 +++++----- lib/helpers.js | 18 +++++++++--------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/cache.js b/lib/cache.js index 1f7a568..8527300 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -40,7 +40,7 @@ function connect_redis() { // the helms file is ignored because we only need 1 file to read/write from function update_file_date(rid, skin_hash) { if (skin_hash) { - var face_path = path.join(__dirname, "..", config.directories.faces, skin_hash + ".png"); + var face_path = path.join(config.directories.faces, skin_hash + ".png"); fs.exists(face_path, function(exists) { if (exists) { var date = new Date(); diff --git a/lib/cleaner.js b/lib/cleaner.js index 53924c5..443f2ba 100644 --- a/lib/cleaner.js +++ b/lib/cleaner.js @@ -35,7 +35,7 @@ function should_clean_redis(callback) { // callback: error, true|false function should_clean_disk(callback) { df({ - file: path.join(__dirname, "..", config.directories.faces), + file: config.directories.faces, prefixMultiplier: "KiB", isDisplayPrefixMultiplier: false, precision: 2 @@ -71,10 +71,10 @@ exp.run = function() { logging.error(err); } else if (clean) { logging.warn("DiskCleaner: Disk limit reached! Cleaning images now"); - var facesdir = path.join(__dirname, "..", config.directories.faces); - var helmdir = path.join(__dirname, "..", config.directories.helms); - var renderdir = path.join(__dirname, "..", config.directories.renders); - var skindir = path.join(__dirname, "..", config.directories.skins); + var facesdir = config.directories.faces; + var helmdir = config.directories.helms; + var renderdir = config.directories.renders; + var skindir = config.directories.skins; fs.readdir(facesdir, function (readerr, files) { if (!readerr) { for (var i = 0, l = Math.min(files.length, config.cleaner.amount); i < l; i++) { diff --git a/lib/helpers.js b/lib/helpers.js index 549e35a..c76a319 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -30,9 +30,9 @@ function store_skin(rid, userId, profile, cache_details, callback) { }); } else { logging.debug(rid, "new skin hash:", skin_hash); - var facepath = path.join(__dirname, "..", config.directories.faces, skin_hash + ".png"); - var helmpath = path.join(__dirname, "..", config.directories.helms, skin_hash + ".png"); - var skinpath = path.join(__dirname, "..", config.directories.skins, skin_hash + ".png"); + var facepath = path.join(config.directories.faces, skin_hash + ".png"); + var helmpath = path.join(config.directories.helms, skin_hash + ".png"); + var skinpath = path.join(config.directories.skins, skin_hash + ".png"); fs.exists(facepath, function(exists) { if (exists) { logging.debug(rid, "skin already exists, not downloading"); @@ -87,7 +87,7 @@ function store_cape(rid, userId, profile, cache_details, callback) { }); } else { logging.debug(rid, "new cape hash:", cape_hash); - var capepath = path.join(__dirname, "..", config.directories.capes, cape_hash + ".png"); + var capepath = path.join(config.directories.capes, cape_hash + ".png"); fs.exists(capepath, function(exists) { if (exists) { logging.debug(rid, "cape already exists, not downloading"); @@ -261,8 +261,8 @@ exp.get_image_hash = function(rid, userId, type, callback) { exp.get_avatar = function(rid, userId, helm, size, callback) { exp.get_image_hash(rid, userId, "skin", function(err, status, skin_hash) { if (skin_hash) { - var facepath = path.join(__dirname, "..", config.directories.faces, skin_hash + ".png"); - var helmpath = path.join(__dirname, "..", config.directories.helms, skin_hash + ".png"); + var facepath = path.join(config.directories.faces, skin_hash + ".png"); + var helmpath = path.join(config.directories.helms, skin_hash + ".png"); var filepath = facepath; fs.exists(helmpath, function(exists) { if (helm && exists) { @@ -288,7 +288,7 @@ exp.get_avatar = function(rid, userId, helm, size, callback) { exp.get_skin = function(rid, userId, callback) { exp.get_image_hash(rid, userId, "skin", function(err, status, skin_hash) { if (skin_hash) { - var skinpath = path.join(__dirname, "..", config.directories.skins, skin_hash + ".png"); + var skinpath = path.join(config.directories.skins, skin_hash + ".png"); fs.exists(skinpath, function(exists) { if (exists) { logging.debug(rid, "skin already exists, not downloading"); @@ -323,7 +323,7 @@ exp.get_render = function(rid, userId, scale, helm, body, callback) { callback(err, status, skin_hash, null); return; } - var renderpath = path.join(__dirname, "..", config.directories.renders, [skin_hash, scale, get_type(helm, body)].join("-") + ".png"); + var renderpath = path.join(config.directories.renders, [skin_hash, scale, get_type(helm, body)].join("-") + ".png"); fs.exists(renderpath, function(exists) { if (exists) { renders.open_render(rid, renderpath, function(render_err, rendered_img) { @@ -362,7 +362,7 @@ exp.get_cape = function(rid, userId, callback) { callback(err, null, status, null); return; } - var capepath = path.join(__dirname, "..", config.directories.capes, cape_hash + ".png"); + var capepath = path.join(config.directories.capes, cape_hash + ".png"); fs.exists(capepath, function(exists) { if (exists) { logging.debug(rid, "cape already exists, not downloading");