var metaAge = 24*3600*1000*(repoinfo.updateinterval);
var expireAge = 24*3600*1000*(repoinfo.expiretime);
+
function fileCheck(i) {
+ var wasExpired = false;
+ var inDownload = false;
+
log.debug("checking file: ", files[i]);
+ log.debug("checking if file is in download mode");
+
+ // need to check global.repoproxy.downloads
+ if(typeof global.repoproxy.downloads[files[i]] != "undefined") {
+ if(global.repoproxy.downloads[files[i]] == 1) {
+ inDownload=true;
+ }
+ }
+
+
// we look for repodata/repomd.xml file, if this is past maturity, we clean that whole directory
- if(files[i].match(/.*repodata\/repomd\.xml$/)) {
- log.debug("Found repomd.xml file: ", files[i]);
-
- // strip the repomd file to get the dir
- var repomddir = files[i].replace(/repomd\.xml$/, "");
- log.debug("repomd dir is:", repomddir);
-
-
- // do the file stat
- fs.stat(files[i], function(err, stats) {
- log.debug("stats for file was: ", stats);
- var curtime = new Date().getTime();
- var ctime = stats.ctime.getTime();
- log.debug("curtime is ", curtime);
- log.debug("ctime is ", ctime);
+ if(!inDownload) {
+ if(files[i].match(/.*repodata\/repomd\.xml$/)) {
+ log.debug("Found repomd.xml file: ", files[i]);
- var age = curtime - ctime;
- log.debug("age is (%d) for (%d)", age, metaAge);
- if(age > metaAge) {
- cache.moveToCleanup(repomddir);
- log.info("Sending repomd directory to trash for cleanup (%s)", repomddir);
- }
- })
-
- } else {
- // STUFF!!!
- fs.stat(files[i], function(err, stats) {
- log.debug("stats for file was: ", stats);
- var curtime = new Date().getTime();
- var atime = stats.atime.getTime();
- log.debug("curtime is ", curtime);
- log.debug("ctime is ", atime);
+ // strip the repomd file to get the dir
+ var repomddir = files[i].replace(/repomd\.xml$/, "");
+ log.debug("repomd dir is:", repomddir);
+
- var age = curtime - atime;
- //log.debug("age is (%d) for (%d)", age, expireAge);
- if(age > expireAge) {
- // TODO: cleanup singular file
- // TODO: cleanup meta too, fuck me
- //log.debug("clean up file \n", files[i]);
- var metafile = files[i].replace(/(.*)\/(.[^\/]+$)/, "$1/.meta.$2.filesize");
- //log.debug("meta for this file is \n", nfile);
- cache.moveToCleanup(files[i]);
- cache.moveToCleanup(metafile);
- log.info("Sending expired file to trash for cleanup (%s)", files[i]);
- }
- })
+ // do the file stat
+ fs.stat(files[i], function(err, stats) {
+ log.debug("stats for file was: ", stats);
+ var curtime = new Date().getTime();
+ var ctime = stats.ctime.getTime();
+ log.debug("curtime is ", curtime);
+ log.debug("ctime is ", ctime);
+
+ var age = curtime - ctime;
+ log.debug("age is (%d) for (%d)", age, metaAge);
+ if(age > metaAge) {
+ cache.moveToCleanup(repomddir);
+ log.info("Sending repomd directory to trash for cleanup (%s)", repomddir);
+ wasExpired = true;
+ }
+ })
+
+ } else {
+ // STUFF!!!
+ fs.stat(files[i], function(err, stats) {
+ log.debug("stats for file was: ", stats);
+ var curtime = new Date().getTime();
+ var atime = stats.atime.getTime();
+ log.debug("curtime is ", curtime);
+ log.debug("ctime is ", atime);
+
+ var age = curtime - atime;
+ //log.debug("age is (%d) for (%d)", age, expireAge);
+ if(age > expireAge) {
+ // TODO: cleanup singular file
+ // TODO: cleanup meta too, fuck me
+ //log.debug("clean up file \n", files[i]);
+ var metafile = files[i].replace(/(.*)\/(.[^\/]+$)/, "$1/.meta.$2.filesize");
+ //log.debug("meta for this file is \n", nfile);
+ cache.moveToCleanup(files[i]);
+ cache.moveToCleanup(metafile);
+ log.info("Sending expired file to trash for cleanup (%s)", files[i]);
+ wasExpired = true;
+ }
+ })
+ }
+ } else {
+ log.debug("file %s was ignored as its in download", files[i]);
}
- if(typeof files[i+1] != "undefined") fileCheck(i+1);
+ if(typeof files[i+1] != "undefined") fileCheck(i+1);
}
if(typeof files[0] != 'undefined') fileCheck(0)