1 var fs = require("fs");
4 function maintainCache() {
5 // TODO i should check that im already running here and exit if i am
6 console.log("Cache maintainence routine starting...");
7 console.log("Cache maintainence routine ended...");
10 exports.startTimer = function() {
11 // our once-a-day cache maintainer
12 var cacheTimer = global.repoproxy.scancache*3600*1000;
13 //var cacheTimer = global.repoproxy.scancache*100;
14 setInterval(maintainCache, cacheTimer);
18 // the service file routine .... PLEASE KILL ME!
19 function serviceFile(reqpath, res, range) {
21 // for now, ignore range.
23 fs.exists(reqpath, function(exists) {
25 var inp = fs.createReadStream(reqpath);
26 inp.setEncoding("utf8");
27 inp.on("data", function(data) {
31 inp.on("end", function(closed) {
36 // TODO, we need to send this upstream, if its upstream we go up.
37 res.writeHead(404, {"Content-Type": "text/plain"});
38 res.write("404 Not Found\n");
44 exports.serviceFile = serviceFile;