From bbc05414cf6aa24faa364afb48119f802b50bda2 Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Tue, 3 Mar 2009 11:21:08 -0500 Subject: Update cleanup script to remove non-unsupported files. Signed-off-by: Loui Chang --- scripts/cleanup | 2 +- web/lib/pkgfuncs.inc | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/cleanup b/scripts/cleanup index 4fc9ea2..21c913a 100755 --- a/scripts/cleanup +++ b/scripts/cleanup @@ -25,7 +25,7 @@ exec('ls ' . INCOMING_DIR, $files); $count = 0; foreach ($files as $pkgname) { - if (!package_exists($pkgname)) { + if (package_location($pkgname) != 'unsupported') { echo 'Removing ' . INCOMING_DIR . "$pkgname\n"; system('rm -r ' . INCOMING_DIR . $pkgname); $count++; diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index b95f910..9d7a0db 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -84,6 +84,21 @@ function pkgLocations() { return $locs; } +# Return the repository name for a particular package. +function package_location($name="") { + if (!$name) {return NULL;} + $dbh = db_connect(); + $q = "SELECT PackageLocations.Location FROM Packages "; + $q.= "LEFT JOIN PackageLocations ON "; + $q.= "Packages.LocationID = PackageLocations.ID "; + $q.= "WHERE Name = '".mysql_real_escape_string($name)."' "; + $q.= "AND DummyPkg = 0"; + $result = db_query($q, $dbh); + if (!$result) {return NULL;} + $row = mysql_fetch_row($result); + return $row[0]; +} + # check to see if the package name exists # function package_exists($name="") { -- cgit v1.2.3-70-g09d2