comparison moefetch.sh @ 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
comparison
equal deleted inserted replaced
178:3f5ee8b2791f 179:c132eb3ca841
123 } 123 }
124 124
125 # verify required folders exist and writeable 125 # verify required folders exist and writeable
126 Check_Folders(){ 126 Check_Folders(){
127 [ -O "${BASE_DIR}" ] || Err_Fatal "You don't own ${BASE_DIR}. Please fix ${BASE_DIR}." 127 [ -O "${BASE_DIR}" ] || Err_Fatal "You don't own ${BASE_DIR}. Please fix ${BASE_DIR}."
128 for FOLDER in temp trash deleted ${SITE_DIR}/${TARGET_DIR} 128 for FOLDER in temp trash deleted "${SITE_DIR}/${TARGET_DIR}"
129 do 129 do
130 if [ ! -d "${BASE_DIR}/${FOLDER}" ]; then 130 if [ ! -d "${BASE_DIR}/${FOLDER}" ]; then
131 mkdir "${BASE_DIR}/${FOLDER}" || Err_Fatal "${FOLDER} folder creation failed" 131 mkdir "${BASE_DIR}/${FOLDER}" || Err_Fatal "${FOLDER} folder creation failed"
132 fi 132 fi
133 if [ ! -O "${BASE_DIR}/${FOLDER}" ]; then 133 if [ ! -O "${BASE_DIR}/${FOLDER}" ]; then
152 152
153 # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR} 153 # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}
154 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" 154 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}"
155 TRASH_DIR="${SITE_DIR}-${TARGET_DIR}-`date -u +%Y%m%d-%H.%M`" 155 TRASH_DIR="${SITE_DIR}-${TARGET_DIR}-`date -u +%Y%m%d-%H.%M`"
156 mkdir -p "${BASE_DIR}/trash/${TRASH_DIR}" 156 mkdir -p "${BASE_DIR}/trash/${TRASH_DIR}"
157 for TRASH in `ls | sed -e 's/\([0-9a-f]\{32\}.*\)//g' | grep -v ^$` 157 # FIXME FIXME FIXME FIXME FIXME FIXME
158 for TRASH in *
158 do 159 do
159 mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files" 160 if [ -d "${TRASH}" ]; then
160 echo "Moved ${TRASH} to ${BASE_DIR}/trash/${TRASH_DIR}" 161 mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files"
162 echo "Moved ${TRASH} to ${BASE_DIR}/trash/${TRASH_DIR}"
163 else
164 TRASH="`echo ${TRASH} | sed -e 's/\([0-9a-f]\{32\}.*\)//g' | grep -v ^$`"
165 if [ "${TRASH}" ]; then
166 mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files"
167 echo "Moved ${TRASH} to ${BASE_DIR}/trash/${TRASH_DIR}"
168 fi
169 fi
161 done 170 done
162 [ "`ls "${BASE_DIR}/trash/${TRASH_DIR}"`" ] || rmdir "${BASE_DIR}/trash/${TRASH_DIR}" 171 [ "`ls "${BASE_DIR}/trash/${TRASH_DIR}"`" ] || rmdir "${BASE_DIR}/trash/${TRASH_DIR}"
163 printf "" > "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error" 172 printf "" > "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error"
164 for FILE in * 173 for FILE in *
165 do 174 do