From f8d7e57ea25a60e2dad75a7675cfee16a167f3f5 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 20 Jul 2009 18:58:08 -0400 Subject: ftpdir-cleanup: Fix the symlink restore loop Previous logic was stupid... let's just check the missing files. If it's missing and exists in the any dir, then common sense says we deleted a symlink somewhere... Signed-off-by: Aaron Griffin --- misc-scripts/ftpdir-cleanup | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/misc-scripts/ftpdir-cleanup b/misc-scripts/ftpdir-cleanup index 7de64b9..2573cf4 100755 --- a/misc-scripts/ftpdir-cleanup +++ b/misc-scripts/ftpdir-cleanup @@ -98,32 +98,17 @@ if [ -z "$DELETEFILES$MISSINGFILES$EXTRAFILES$ARCHINDEPFILES" ]; then exit 0 fi -#Do a quick check. If we have a MISSINGFILE and an ARCHINDEPFILE of the same -#name to remove, then let's restore the symlink. - -archfiles="$ARCHINDEPFILES" -ARCHINDEPFILES="" -for af in $archfiles; do - af_satisfied=0 - for mf in $MISSINGFILES; do - if [ "${af}" = "${mf}" ]; then - ln -s "${ftppath_base}/any/${af}" "${ftppath}" - af_satisfied=1 - fi - - done - if [ $af_satisfied -eq 0 ]; then - ARCHINDEPFILES="${ARCHINDEPFILES} ${af}" - fi -done -#rescan missing files now +# Do a quick check to see if a missing ARCHINDEPFILE is in the any dir +# If it is, and the file is MISSING, restore it missfiles="$MISSINGFILES" MISSINGFILES="" for mf in $missfiles; do - if [ ! -e "${ftppath}/${mf}" ]; then - MISSINGFILES="${MISSINGFILES} ${mf}" + af_satisfied=0 + if [ -e "${ftppath_base}/any/${mf}" ]; then + echo "Restoring missing 'any' symlink: ${mf}" + ln -s "${ftppath_base}/any/${mf}" "${ftppath}" else - echo "Missing file has been restored: $mf" + MISSINGFILES="${MISSINGFILES} ${mf}" fi done -- cgit v1.2.3-2-g168b