X-Git-Url: http://git.pjr.cc/?p=nodejs-repoproxy.git;a=blobdiff_plain;f=lib%2Fcache.js;fp=lib%2Fcache.js;h=3e9ec770456645f90549b9980f4cc91885b9dd73;hp=e065a2a160806d587a5ef1833b21d55f36c0ff51;hb=3fa5e831263792a76c9430b9d86e353901bc4477;hpb=68fbf923faf99f86cc36dc5776451f89925df8bd diff --git a/lib/cache.js b/lib/cache.js index e065a2a..3e9ec77 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -15,7 +15,7 @@ exports.startTimer = function() { setInterval(maintainCache, cacheTimer); } -function upstreamRequest(unify, callback) { +function upstreamRequest(unify) { // first do a head request console.log("upsteram as ", unify.requestFor); @@ -98,8 +98,9 @@ exports.upstreamRequest = upstreamRequest; function getAndService(unify, xpath) { - if(global.repoproxy.downloads[unify.fullFilePath] == 1) { + if(typeof global.repoproxy.downloads[unify.fullFilePath] != "undefined" && global.repoproxy.downloads[unify.fullFilePath] == 1) { + console.log("service inline"); unify.b.write("trying to service inline"); unify.b.end(); } else { @@ -125,6 +126,10 @@ function getAndService(unify, xpath) { file.end(); global.repoproxy.downloads[unify.fullFilePath] = 0; }); + + res.on("error", function(err) { + console.log("res threw error... ", err); + }); }); } } @@ -136,7 +141,7 @@ function serviceFile(unify) { // file should already exist, so we just poop it out var inp = fs.createReadStream(unify.fullFilePath); - inp.setEncoding("utf8"); + //inp.setEncoding("utf8"); inp.on("data", function(data) { unify.b.write(data); }); @@ -170,7 +175,7 @@ function serviceDirectory(unify) { var res = unify.b; res.write("

Directory listing for " + unify.originalReq + "


");
-	if(unify.fullFilePath != "/") res.write("Parent\n\n");
+	if(unify.originalReq != "/") res.write("Parent\n\n");
 	fs.readdir(unify.fullFilePath, function(err, files) {
 		console.log("doing directory listing on: ", unify.fullFilePath);
 		if(err == null) {