changeset 179:c132eb3ca841

improved folder checker
author edhoprima@gmail.com <edhoprima@gmail.com>
date Fri, 05 Jun 2009 21:12:45 +0000
parents 3f5ee8b2791f
children 8e6555aa8631
files moefetch.sh
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/moefetch.sh	Fri Jun 05 20:41:40 2009 +0000
+++ b/moefetch.sh	Fri Jun 05 21:12:45 2009 +0000
@@ -125,7 +125,7 @@
 # verify required folders exist and writeable
 Check_Folders(){
 	[ -O "${BASE_DIR}" ] || Err_Fatal "You don't own ${BASE_DIR}. Please fix ${BASE_DIR}."
-	for FOLDER in temp trash deleted ${SITE_DIR}/${TARGET_DIR}
+	for FOLDER in temp trash deleted "${SITE_DIR}/${TARGET_DIR}"
 	do
 		if [ ! -d "${BASE_DIR}/${FOLDER}" ]; then
 			mkdir "${BASE_DIR}/${FOLDER}" || Err_Fatal "${FOLDER} folder creation failed"
@@ -154,10 +154,19 @@
 		cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}"
 		TRASH_DIR="${SITE_DIR}-${TARGET_DIR}-`date -u +%Y%m%d-%H.%M`"
 		mkdir -p "${BASE_DIR}/trash/${TRASH_DIR}"
-		for TRASH in `ls | sed -e 's/\([0-9a-f]\{32\}.*\)//g' | grep -v ^$`
+		# FIXME FIXME FIXME FIXME FIXME FIXME 
+		for TRASH in *
 		do
-			mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files"
-			echo "Moved ${TRASH} to ${BASE_DIR}/trash/${TRASH_DIR}"
+			if [ -d "${TRASH}" ]; then
+				mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files"
+				echo "Moved ${TRASH} to ${BASE_DIR}/trash/${TRASH_DIR}"
+			else
+				TRASH="`echo ${TRASH} | sed -e 's/\([0-9a-f]\{32\}.*\)//g' | grep -v ^$`"
+				if [ "${TRASH}" ]; then
+					mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files"
+					echo "Moved ${TRASH} to ${BASE_DIR}/trash/${TRASH_DIR}"
+				fi
+			fi
 		done
 		[ "`ls "${BASE_DIR}/trash/${TRASH_DIR}"`" ] || rmdir "${BASE_DIR}/trash/${TRASH_DIR}"
 		printf "" > "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error"