comparison moefetch.sh @ 207:17d816a63b4c

final progress version
author edhoprima@gmail.com <edhoprima@gmail.com>
date Mon, 29 Jun 2009 17:11:01 +0000
parents a44ba2e495a1
children 92505dfbb346
comparison
equal deleted inserted replaced
206:a44ba2e495a1 207:17d816a63b4c
174 Cleanup_Repository() { 174 Cleanup_Repository() {
175 175
176 # THE FILES 176 # THE FILES
177 177
178 # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR} 178 # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}
179 printf "Cleaning up repository folder..." 179 printf "Cleaning up repository folder... "
180 Progress_Init 180 Progress_Init
181 TRASH_DIR=$(date -u "+${SITE_DIR}-${TARGET_DIR}-%Y%m%d-%H.%M") 181 TRASH_DIR=$(date -u "+${SITE_DIR}-${TARGET_DIR}-%Y%m%d-%H.%M")
182 mkdir -p "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Unable to create trash folder" 182 mkdir -p "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Unable to create trash folder"
183 for TRASH in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"* 183 for TRASH in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"*
184 do 184 do
204 204
205 # check files correctness 205 # check files correctness
206 Check_Files() { 206 Check_Files() {
207 if [ ! "${ISNEW}" ]; then 207 if [ ! "${ISNEW}" ]; then
208 [ "${NOCLEAN}" ] || Cleanup_Repository 208 [ "${NOCLEAN}" ] || Cleanup_Repository
209 printf "Checking for errors..." 209 printf "Checking for errors... "
210 Progress_Init 210 Progress_Init
211 > "${TEMP_PREFIX}-error" 211 > "${TEMP_PREFIX}-error"
212 for FILE in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"* 212 for FILE in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"*
213 do 213 do
214 if [ "$(echo "${FILE}" | sed -e "${SED_GET_FILENAME};${SED_IS_MD5_FILE}" | grep -v ^$)" ]; then 214 if [ "$(echo "${FILE}" | sed -e "${SED_GET_FILENAME};${SED_IS_MD5_FILE}" | grep -v ^$)" ]; then
232 cat "${TEMP_PREFIX}-error" | xargs rm 232 cat "${TEMP_PREFIX}-error" | xargs rm
233 echo " ${TOTAL_ERROR} file(s) removed" 233 echo " ${TOTAL_ERROR} file(s) removed"
234 fi 234 fi
235 echo "$(Count_Files "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}") file(s) available locally" 235 echo "$(Count_Files "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}") file(s) available locally"
236 236
237 printf "Generating list of new files..." 237 printf "Generating list of new files... "
238 Progress_Init 238 Progress_Init
239 # THE FILES 239 # THE FILES
240 #ls "../${TARGET_DIR}" | grep -vf "${TARGET_DIR}-error" > "${TARGET_DIR}-ok" 240 #ls "../${TARGET_DIR}" | grep -vf "${TARGET_DIR}-error" > "${TARGET_DIR}-ok"
241 # 241 #
242 find "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" | comm -1 -3 "${TEMP_PREFIX}-error" - | sed -e "${SED_GET_FILENAME}" > "${TEMP_PREFIX}-ok" 242 find "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" | comm -1 -3 "${TEMP_PREFIX}-error" - | sed -e "${SED_GET_FILENAME}" > "${TEMP_PREFIX}-ok"
250 #cat "${TEMP_PREFIX}-list" | egrep -vf "${TEMP_PREFIX}-ok" > "${TEMP_PREFIX}-newlist" 250 #cat "${TEMP_PREFIX}-list" | egrep -vf "${TEMP_PREFIX}-ok" > "${TEMP_PREFIX}-newlist"
251 echo "$(echo $(wc -l < "${TEMP_PREFIX}-newlist")) file(s) to be downloaded" 251 echo "$(echo $(wc -l < "${TEMP_PREFIX}-newlist")) file(s) to be downloaded"
252 252
253 else 253 else
254 if [ "${ISQUICK}" ]; then 254 if [ "${ISQUICK}" ]; then
255 echo "quick mode selected. Skipping check" 255 echo "Quick mode selected. Skipping check"
256 else 256 else
257 echo "Empty local repository" 257 echo "Empty local repository"
258 fi 258 fi
259 cat "${TEMP_PREFIX}-list" > "${TEMP_PREFIX}-newlist" 259 cat "${TEMP_PREFIX}-list" > "${TEMP_PREFIX}-newlist"
260 fi 260 fi
263 # start downloading the images 263 # start downloading the images
264 Fetch_Images() { 264 Fetch_Images() {
265 if [ "$(echo $(wc -l < "${TEMP_PREFIX}-newlist"))" -eq 0 ]; then 265 if [ "$(echo $(wc -l < "${TEMP_PREFIX}-newlist"))" -eq 0 ]; then
266 echo "No new file" 266 echo "No new file"
267 else 267 else
268 printf "Starting wget..." 268 printf "Starting wget... "
269 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" 269 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}"
270 wget -e continue=on -bi "${TEMP_PREFIX}-newlist" -o "${TEMP_PREFIX}.log" 270 wget -e continue=on -bi "${TEMP_PREFIX}-newlist" -o "${TEMP_PREFIX}.log"
271 fi 271 fi
272 } 272 }
273 273