Mercurial > ec-dotfiles
changeset 205:2e866999c042
now with useless animation
author | edhoprima@gmail.com <edhoprima@gmail.com> |
---|---|
date | Mon, 29 Jun 2009 17:03:35 +0000 |
parents | fb02adf58c00 |
children | a44ba2e495a1 |
files | moefetch.sh |
diffstat | 1 files changed, 29 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/moefetch.sh Mon Jun 29 16:46:59 2009 +0000 +++ b/moefetch.sh Mon Jun 29 17:03:35 2009 +0000 @@ -103,6 +103,23 @@ #output file: ${TARGET_DIR}-list } +Progress_Init() { + _last="-" + printf "${_last}" +} + +Progress_Anim() { + case "${_last}" in + /) _last="-";; + -) _last=\\;; + \\) _last=\|;; + \|) _last="/";; + esac + printf "\b${_last}" +} + +Progress_Done() { printf "\bdone\n"; } + # getting rid of ls (as per suggestion) Count_Files() { _i=0 @@ -159,7 +176,8 @@ # THE FILES # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR} - printf "Cleaning up repository folder" + printf "Cleaning up repository folder..." + Progress_Init TRASH_DIR=$(date -u "+${SITE_DIR}-${TARGET_DIR}-%Y%m%d-%H.%M") mkdir -p "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Unable to create trash folder" for TRASH in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"* @@ -178,22 +196,23 @@ mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files" echo "Moved $(echo "${TRASH}" | sed -e "${SED_GET_FILENAME}") to ${BASE_DIR}/trash/${TRASH_DIR}" fi - printf "." + Progress_Anim done - echo "done" rmdir "${BASE_DIR}/trash/${TRASH_DIR}" 2>/dev/null + Progress_Done } # check files correctness Check_Files() { if [ ! "${ISNEW}" ]; then [ "${NOCLEAN}" ] || Cleanup_Repository - printf "Checking for errors" + printf "Checking for errors..." + Progress_Init > "${TEMP_PREFIX}-error" for FILE in "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}/"* do if [ "$(echo "${FILE}" | sed -e "${SED_GET_FILENAME};${SED_IS_MD5_FILE}" | grep -v ^$)" ]; then - printf "\nNot a valid danbooru file: $(echo ${FILE} | sed -e "${SED_GET_FILENAME}")\n" + printf "\nNot a valid danbooru file: $(echo ${FILE} | sed -e "${SED_GET_FILENAME}")\n${_last}" else if [ "$(${MD5} "${FILE}" | cut -d ' ' -f1 -)" != "$(echo "${FILE}" | sed -e "${SED_GET_FILENAME}" | cut -d '.' -f1)" ] then @@ -201,10 +220,10 @@ echo echo "Error: $(echo "${FILE}" | sed -e "${SED_GET_FILENAME}")" fi - printf "." + Progress_Anim fi done - echo "done" + Progress_Done TOTAL_ERROR=$(echo $(wc -l < "${TEMP_PREFIX}-error")) if [ "${TOTAL_ERROR}" -eq 0 ]; then echo "All files OK" @@ -216,6 +235,7 @@ echo "$(Count_Files "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}") file(s) available locally" printf "Generating list of new files..." + Progress_Init # THE FILES #ls "../${TARGET_DIR}" | grep -vf "${TARGET_DIR}-error" > "${TARGET_DIR}-ok" # @@ -224,10 +244,10 @@ while read -r IS_OK; do cat "${TEMP_PREFIX}-templist" | grep -v "${IS_OK}" > "${TEMP_PREFIX}-newlist" cat "${TEMP_PREFIX}-newlist" > "${TEMP_PREFIX}-templist" - printf "." + Progress_Anim done < "${TEMP_PREFIX}-ok" + Progress_Done #cat "${TEMP_PREFIX}-list" | egrep -vf "${TEMP_PREFIX}-ok" > "${TEMP_PREFIX}-newlist" - echo " done" echo "$(echo $(wc -l < "${TEMP_PREFIX}-newlist")) file(s) to be downloaded" else