From: Paul J R Date: Tue, 25 Jun 2013 22:45:39 +0000 (+1000) Subject: fixing repo bits X-Git-Url: http://git.pjr.cc/?p=nodejs-repoproxy.git;a=commitdiff_plain;h=d1bf8734f65364457e522c74fb3615d5f017874c fixing repo bits --- diff --git a/TODO b/TODO index 7d7a5f8..c67b9f1 100644 --- a/TODO +++ b/TODO @@ -2,4 +2,13 @@ TODO ==== - fix the log.* entries that need to be errors -- metadata check on maintenance routines \ No newline at end of file +- metadata check on maintenance routines +- fix the upstream request pipeline, many dead ends here + + +events.js:71 + throw arguments[1]; // Unhandled 'error' event + ^ +Error: getaddrinfo ENOTFOUND + at errnoException (dns.js:37:11) + at Object.onanswer [as oncomplete] (dns.js:124:16) diff --git a/lib/repo-yum.js b/lib/repo-yum.js index ab88039..57741ba 100644 --- a/lib/repo-yum.js +++ b/lib/repo-yum.js @@ -32,6 +32,9 @@ function maintain(name, repoinfo, files) { // we look for repodata/repomd.xml file, if this is past maturity, we clean that whole directory if(!inDownload) { + + var metafile = files[i].replace(/(.*)\/(.[^\/]+$)/, "$1/.meta.$2.filesize"); + if(files[i].match(/.*repodata\/repomd\.xml$/)) { log.debug("Found repomd.xml file: ", files[i]); @@ -72,7 +75,6 @@ function maintain(name, repoinfo, files) { // 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); @@ -81,6 +83,27 @@ function maintain(name, repoinfo, files) { } }) } + + // check meta data + fs.stat(files[i], function(err, stats) { + var fsize = stats.size; + var mfile = fs.createReadStream(metafile); + var expSize = ""; + mfile.on("data", function(data) { + expSize += data; + }); + + mfile.on("end", function(closed) { + if(fsize != parseInt(expSize)) { + log.debug("possible metadata clash for (%s) - (%d),(%s), removing file", files[i], fsize, expSize); + cache.moveToCleanup(files[i]); + cache.moveToCleanup(metafile); + } else { + log.debug("metadata good for (%s) - (%d),(%s)", files[i], fsize, expSize); + } + }); + + }) } else { log.debug("file %s was ignored as its in download", files[i]); }