X-Git-Url: http://git.pjr.cc/?p=nodejs-repoproxy.git;a=blobdiff_plain;f=lib%2Frepo-apt.js;h=f852086f3eb164ccd4a52ce87dfe4b1f7fea3469;hp=fbe433e88334e5ca5988fe216804e449e060cd6d;hb=3e02ce60811b9dbd3b166fe38058f0a00ab00a2d;hpb=29883864086599c58c4dce0fd734a2483d4c0c11 diff --git a/lib/repo-apt.js b/lib/repo-apt.js index fbe433e..f852086 100644 --- a/lib/repo-apt.js +++ b/lib/repo-apt.js @@ -2,14 +2,20 @@ var fs = require("fs"); var http = require("http"); var url = require("url"); var path = require("path"); +var log = require("./log.js"); + + +/* + * For APT repos, we expire anything with .* /dist/ .* in thename + */ function maintain(name, repoinfo, files) { - //console.log("doing apt clean for ", repoinfo); + //log.debug("doing apt clean for ", repoinfo); var topdir = path.normalize(global.repoproxy.cacheDir + "/" + name + "/"); function fileCheck(i) { - console.log("checking file: ", files[i]); + log.debug("checking file: ", files[i]); var cfile = files[i].replace(topdir, ""); var ctime_t = new Date(); @@ -20,26 +26,26 @@ function maintain(name, repoinfo, files) { // file checks go here if(typeof global.repoproxy.downloads[files[i]] != "undefined" && global.repoproxy.downloads[files[i]] == 1) { // ignore this file as its being downloaded - console.log("not checking file because its downloading ", cfile); + log.debug("not checking file because its downloading ", cfile); if(typeof files[i+1] != "undefined") fileCheck(i+1); } else { fs.stat(files[i], function(err, stats) { - //console.log("deep check", cfile); + //log.debug("deep check", cfile); if(cfile.match(/.*dists\/.*/) != null) { // its a dist file, probably, check age and erase if necessary if(stats["mtime"].getTime() < time_ui) { // erase file - console.log("unlinking file for time_ui: ", files[i]) + log.debug("unlinking file for time_ui: ", files[i]) //fs.unlink(files[i]); } else { - //console.log("times for file '%s', '%s', '%s', '%s'", cfile, time_ui, time_et, stats["mtime"].getTime()); + //log.debug("times for file '%s', '%s', '%s', '%s'", cfile, time_ui, time_et, stats["mtime"].getTime()); } } else { // its just some other file, check the read time if(stats["atime"].getTime() < time_et) { - console.log("unlinking file for time_et: ", files[i]); + log.debug("unlinking file for time_et: ", files[i]); } } if(typeof files[i+1] != "undefined") fileCheck(i+1); @@ -51,7 +57,7 @@ function maintain(name, repoinfo, files) { if(typeof files[0] != 'undefined') fileCheck(0) - else console.log("Skipping file check as there are none... apprently?"); + else log.debug("Skipping (apt) file check as there are none... apprently?"); } exports.maintain = maintain; \ No newline at end of file