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();
// 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);
}
- fileCheck(0)
+
+ if(typeof files[0] != 'undefined') fileCheck(0)
+ else log.debug("Skipping (apt) file check as there are none... apprently?");
}
exports.maintain = maintain;
\ No newline at end of file