changeset 170:0d385f77bb24

derp
author edhoprima@gmail.com <edhoprima@gmail.com>
date Fri, 05 Jun 2009 19:52:21 +0000
parents b9a49b36e4ab
children ba4ea5d19d2b
files moefetch.sh
diffstat 1 files changed, 14 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/moefetch.sh	Fri Jun 05 19:43:23 2009 +0000
+++ b/moefetch.sh	Fri Jun 05 19:52:21 2009 +0000
@@ -145,13 +145,13 @@
 		cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}"
 		for TRASH in `ls * | sed -e 's/\([0-9a-f]\{32\}.*\)//g' | grep -v ^$`
 		do
-			mv -f "${BASE_DIR}/${SITE_DIR}/${TRASH}" "${BASE_DIR}/trash"
+			mv -f "${TRASH}" "${BASE_DIR}/trash" || Err_Fatal "Error deleting files"
 			echo "Moved ${TRASH} to ${BASE_DIR}/trash"
 		done
 		printf "" > "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error"
 		for FILE in *
 		do
-			if [ "`${MD5} "${FILE}" | cut -d ' ' -f1 -` != `echo "${FILE}" | cut -d '.' -f1`" ]
+			if [ "`${MD5} "${FILE}" | cut -d ' ' -f1 -`" != "`echo "${FILE}" | cut -d '.' -f1`" ]
 			then
 				echo
 				echo "${FILE}" >> "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error"
@@ -161,6 +161,18 @@
 		done
 		echo
 		
+		# back to target dir
+		cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}"
+
+		echo "Removing error files"
+		if [ "${TOTAL_ERROR}" -eq 0 ]; then
+			echo "No error file. 0 file removed"
+		else
+			cat "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error" | xargs rm
+			echo "${TOTAL_ERROR} file(s) removed"
+		fi
+		echo "`echo \`ls | wc -l\`` file(s) available locally"
+
 		# current dir: ${BASE_DIR}/temp
 		cd ${BASE_DIR}/temp
 		TOTAL_ERROR=`echo \`wc -l < "${SITE_DIR}-${TARGET_DIR}-error"\``
@@ -174,17 +186,6 @@
 		cat "${SITE_DIR}-${TARGET_DIR}-list" | grep -vf "${SITE_DIR}-${TARGET_DIR}-ok" > "${SITE_DIR}-${TARGET_DIR}-newlist"
 		echo "`echo \`wc -l < \"${SITE_DIR}-${TARGET_DIR}-newlist\"\`` file(s) to be downloaded"
 		
-		# back to target dir
-		cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}"
-
-		echo "Removing error files"
-		if [ "${TOTAL_ERROR}" -eq 0 ]; then
-			echo "No error file. 0 file removed"
-		else
-			cat "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error" | xargs rm
-			echo "${TOTAL_ERROR} file(s) removed"
-		fi
-		echo "`echo \`ls | wc -l\`` file(s) available locally"
 	else
 		if [ "${ISQUICK}" ]; then
 			echo "quick mode selected. Skipping check"