|
@@ -2,7 +2,7 @@ var config = require("./config");
|
|
var redis = null;
|
|
var redis = null;
|
|
var fs = require("fs");
|
|
var fs = require("fs");
|
|
|
|
|
|
-// sets up redis connection, calls clear_cache
|
|
|
|
|
|
+// sets up redis connection
|
|
function connect_redis() {
|
|
function connect_redis() {
|
|
console.log("connecting to redis...");
|
|
console.log("connecting to redis...");
|
|
if (process.env.REDISCLOUD_URL) {
|
|
if (process.env.REDISCLOUD_URL) {
|
|
@@ -14,7 +14,6 @@ function connect_redis() {
|
|
}
|
|
}
|
|
redis.on("ready", function() {
|
|
redis.on("ready", function() {
|
|
console.log("Redis connection established.");
|
|
console.log("Redis connection established.");
|
|
- clear_cache();
|
|
|
|
});
|
|
});
|
|
redis.on("error", function (err) {
|
|
redis.on("error", function (err) {
|
|
console.error(err);
|
|
console.error(err);
|
|
@@ -26,34 +25,34 @@ function connect_redis() {
|
|
|
|
|
|
|
|
|
|
// flushes redis, deletes faces + helms
|
|
// flushes redis, deletes faces + helms
|
|
-function clear_cache() {
|
|
|
|
- console.log("Flushing redis");
|
|
|
|
- redis.flushall();
|
|
|
|
- console.log("Deleting all faces + helms...");
|
|
|
|
- fs.readdir(config.faces_dir, function(err, files) {
|
|
|
|
- if (err) {
|
|
|
|
- console.error(err);
|
|
|
|
- } else {
|
|
|
|
- for (var i in files) {
|
|
|
|
- var file = files[i];
|
|
|
|
- if (file[0] != ".") {
|
|
|
|
- // delete face file
|
|
|
|
- fs.unlink(config.faces_dir + file, function(err){
|
|
|
|
- if (err) {
|
|
|
|
- console.error(err);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- // delete helm file, we assume this exists as well
|
|
|
|
- fs.unlink(config.helms_dir + file, function(err){
|
|
|
|
- if (err) {
|
|
|
|
- console.error(err);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-}
|
|
|
|
|
|
+// function clear_cache() {
|
|
|
|
+// console.log("Flushing redis");
|
|
|
|
+// redis.flushall();
|
|
|
|
+// console.log("Deleting all faces + helms...");
|
|
|
|
+// fs.readdir(config.faces_dir, function(err, files) {
|
|
|
|
+// if (err) {
|
|
|
|
+// console.error(err);
|
|
|
|
+// } else {
|
|
|
|
+// for (var i in files) {
|
|
|
|
+// var file = files[i];
|
|
|
|
+// if (file[0] != ".") {
|
|
|
|
+// // delete face file
|
|
|
|
+// fs.unlink(config.faces_dir + file, function(err){
|
|
|
|
+// if (err) {
|
|
|
|
+// console.error(err);
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// // delete helm file, we assume this exists as well
|
|
|
|
+// fs.unlink(config.helms_dir + file, function(err){
|
|
|
|
+// if (err) {
|
|
|
|
+// console.error(err);
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// }
|
|
|
|
|
|
// sets the date of the face file belonging to +hash+ to now
|
|
// sets the date of the face file belonging to +hash+ to now
|
|
// the helms file is ignored because we only need 1 file to read/write from
|
|
// the helms file is ignored because we only need 1 file to read/write from
|