Mercurial > ec-dotfiles
comparison moefetch.sh @ 204:fb02adf58c00
cleanup. speed
author | edhoprima@gmail.com <edhoprima@gmail.com> |
---|---|
date | Mon, 29 Jun 2009 16:46:59 +0000 |
parents | 94a585031e3b |
children | 2e866999c042 |
comparison
equal
deleted
inserted
replaced
203:94a585031e3b | 204:fb02adf58c00 |
---|---|
157 Cleanup_Repository() { | 157 Cleanup_Repository() { |
158 | 158 |
159 # THE FILES | 159 # THE FILES |
160 | 160 |
161 # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR} | 161 # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR} |
162 echo "Cleaning up repository folder..." | 162 printf "Cleaning up repository folder" |
163 TRASH_DIR=$(date -u "+${SITE_DIR}-${TARGET_DIR}-%Y%m%d-%H.%M") | 163 TRASH_DIR=$(date -u "+${SITE_DIR}-${TARGET_DIR}-%Y%m%d-%H.%M") |
164 mkdir -p "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Unable to create trash folder" | 164 mkdir -p "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Unable to create trash folder" |
165 for TRASH in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"* | 165 for TRASH in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"* |
166 do | 166 do |
167 ISTRASH= | 167 ISTRASH= |
176 fi | 176 fi |
177 if [ "${ISTRASH}" ]; then | 177 if [ "${ISTRASH}" ]; then |
178 mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files" | 178 mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files" |
179 echo "Moved $(echo "${TRASH}" | sed -e "${SED_GET_FILENAME}") to ${BASE_DIR}/trash/${TRASH_DIR}" | 179 echo "Moved $(echo "${TRASH}" | sed -e "${SED_GET_FILENAME}") to ${BASE_DIR}/trash/${TRASH_DIR}" |
180 fi | 180 fi |
181 done | 181 printf "." |
182 done | |
183 echo "done" | |
182 rmdir "${BASE_DIR}/trash/${TRASH_DIR}" 2>/dev/null | 184 rmdir "${BASE_DIR}/trash/${TRASH_DIR}" 2>/dev/null |
183 | |
184 } | 185 } |
185 | 186 |
186 # check files correctness | 187 # check files correctness |
187 Check_Files() { | 188 Check_Files() { |
188 if [ ! "${ISNEW}" ]; then | 189 if [ ! "${ISNEW}" ]; then |
189 [ "${NOCLEAN}" ] || Cleanup_Repository | 190 [ "${NOCLEAN}" ] || Cleanup_Repository |
190 printf "Checking for errors..." | 191 printf "Checking for errors" |
191 > "${TEMP_PREFIX}-error" | 192 > "${TEMP_PREFIX}-error" |
192 for FILE in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"* | 193 for FILE in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"* |
193 do | 194 do |
194 if [ "$(echo "${FILE}" | sed -e "${SED_GET_FILENAME};${SED_IS_MD5_FILE}" | grep -v ^$)" ]; then | 195 if [ "$(echo "${FILE}" | sed -e "${SED_GET_FILENAME};${SED_IS_MD5_FILE}" | grep -v ^$)" ]; then |
195 printf "\nNot a valid danbooru file: $(echo ${FILE} | sed -e "${SED_GET_FILENAME}")\n" | 196 printf "\nNot a valid danbooru file: $(echo ${FILE} | sed -e "${SED_GET_FILENAME}")\n" |
201 echo "Error: $(echo "${FILE}" | sed -e "${SED_GET_FILENAME}")" | 202 echo "Error: $(echo "${FILE}" | sed -e "${SED_GET_FILENAME}")" |
202 fi | 203 fi |
203 printf "." | 204 printf "." |
204 fi | 205 fi |
205 done | 206 done |
206 echo " done" | 207 echo "done" |
207 TOTAL_ERROR=$(echo $(wc -l < "${TEMP_PREFIX}-error")) | 208 TOTAL_ERROR=$(echo $(wc -l < "${TEMP_PREFIX}-error")) |
208 if [ "${TOTAL_ERROR}" -eq 0 ]; then | 209 if [ "${TOTAL_ERROR}" -eq 0 ]; then |
209 echo "All files OK" | 210 echo "All files OK" |
210 else | 211 else |
211 printf "${TOTAL_ERROR} file(s) broken: removing..." | 212 printf "${TOTAL_ERROR} file(s) broken: removing..." |