[dbscripts,3/4] ftpdir-cleanup: remove useless loop and make clean_pkg take a targetdir

Message ID 20181204180944.9648-3-eschwartz@archlinux.org
State New
Headers show
Series
  • [dbscripts,1/4] tests: make dummy copies of all pkgpool packages in the test environment
Related show

Commit Message

Eli Schwartz via arch-projects Dec. 4, 2018, 6:09 p.m. UTC
This is never ever called for multiple packages at once, and if it was,
it would be named clean_pkgs. Meanwhile, it was implied that this could
take a variable target, but that was never-used code. Make it useful
because we might (will) use it.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
---
 cron-jobs/ftpdir-cleanup | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

Patch

diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup
index 9df5f99a..74b771cd 100755
--- a/cron-jobs/ftpdir-cleanup
+++ b/cron-jobs/ftpdir-cleanup
@@ -4,21 +4,19 @@ 
 . "$(dirname "$(readlink -e "$0")")/../db-functions"
 
 clean_pkg() {
-	local pkg
-	local target
+	local pkg=${1}
+	local targetdir=${2:-${CLEANUP_DESTDIR}}
 
 	if [[ $CLEANUP_DRYRUN != true ]]; then
-		for pkg in "$@"; do
-			if [[ -h $pkg ]]; then
-				rm -f "$pkg" "$pkg.sig"
-			else
-				mv_acl "$pkg" "$CLEANUP_DESTDIR/${pkg##*/}"
-				if [[ -e $pkg.sig ]]; then
-					mv_acl "$pkg.sig" "$CLEANUP_DESTDIR/${pkg##*/}.sig"
-				fi
-				touch "${CLEANUP_DESTDIR}/${pkg##*/}"
+		if [[ -h ${pkg} ]]; then
+			rm -f "${pkg}" "${pkg}.sig"
+		else
+			mv_acl "${pkg}" "${targetdir}/${pkg##*/}"
+			if [[ -e ${pkg}.sig ]]; then
+				mv_acl "${pkg}.sig" "${targetdir}/${pkg##*/}.sig"
 			fi
-		done
+			touch "${targetdir}/${pkg##*/}"
+		fi
 	fi
 }