From 1e20af9aed1bdd39b6eead4bf74d97e984b3297e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 28 Jul 2011 13:59:05 -0500 Subject: scripts/cleanup: use native PHP only No need to shell out to the system here. Also fix the script so it actually works. Signed-off-by: Dan McGee Signed-off-by: Lukas Fleischer --- scripts/cleanup | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/cleanup b/scripts/cleanup index 4fc9ea2d..f2873501 100755 --- a/scripts/cleanup +++ b/scripts/cleanup @@ -16,21 +16,23 @@ if (empty($dir)) { } set_include_path(get_include_path() . PATH_SEPARATOR . "$dir/lib"); -include("config.inc"); -include("aur.inc"); -include("pkgfuncs.inc"); - -exec('ls ' . INCOMING_DIR, $files); +include("config.inc.php"); +include("aur.inc.php"); +include("pkgfuncs.inc.php"); $count = 0; +$files = scandir(INCOMING_DIR); foreach ($files as $pkgname) { - if (!package_exists($pkgname)) { - echo 'Removing ' . INCOMING_DIR . "$pkgname\n"; - system('rm -r ' . INCOMING_DIR . $pkgname); + if ($pkgname == '.' || $pkgname == '..') { + continue; + } + $fullpath = INCOMING_DIR . $pkgname; + if (!package_exists($pkgname) && is_dir($fullpath)) { + echo 'Removing ' . $fullpath . "\n"; + rm_tree($fullpath); $count++; } } echo "\nRemoved $count directories.\n"; - -- cgit v1.2.3-24-g4f1b