[gen_tracks][env][parser][cmd_export][export_cp] Added debug option and improved error handling

This commit is contained in:
ayakael 2019-02-27 14:49:49 -05:00
parent 6f90cb5fb6
commit 45b2e27c31
Signed by untrusted user who does not match committer: forge
GPG key ID: D62A472A4AA7D541
5 changed files with 21 additions and 8 deletions

View file

@ -58,7 +58,7 @@ cmd_export() {
for removableid in ${removableidList[@]}; do
echo "[ ${COUNT} / ${#removableidList[@]} ] Removing ${removableid}"
export_rm "${TARGET}" "${DB_FILE}" ${removableid} >${STDERR} 2>&1
[[ $? -eq 0 ]] || { echo "[>>>>>>] Error reported"; cat ${STDERR}; local ERR=true; }
[[ $? -eq 0 ]] || { echo "[>>>>>>] Error reported"; cat ${STDERR}; local ERR=true; } && { if ${_DEBUG}; then cat ${STDERR}; fi; }
local COUNT=$(( ${COUNT} + 1 ))
done
@ -75,18 +75,19 @@ cmd_export() {
local GIT_GET=true
[[ ${ERROR} -eq 255 ]] && git -C "${GIT_DIR}" annex get "${imageid}.flac" >/dev/null 2>&1
local ERROR=$?
[[ $ERROR -ne 0 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#exportableidList[@]} ] ${imageid} could not be downloaded from server"; cat ${STDERR}; local ERR=true; continue; }
[[ $ERROR -ne 0 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#exportableidList[@]} ] ${imageid} could not be downloaded from server"; cat ${STDERR}; local ERR=true; continue; } || { if ${_DEBUG}; then cat ${STDERR}; fi; }
fi
export_cp "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} > ${STDERR} 2>&1
[[ $? -ne 0 ]] && local CP_ERR=true
local EXIT=$?
[[ ${EXIT} -ne 0 ]] && local CP_ERR=true
[[ "${GIT_GET}" == "true" ]] && git -C "${GIT_DIR}" annex drop ${imageid}.flac >/dev/null 2>&1
[[ "${CP_ERR}" == "true" ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#exportableidList[@]} ] Copy of ${imageid} completed with errors"; cat ${STDERR}; local ERR=true; continue; }
[[ "${CP_ERR}" == "true" ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#exportableidList[@]} ] Copy of ${imageid} completed with errors"; cat ${STDERR}; local ERR=true; continue; } || { if ${_DEBUG}; then cat ${STDERR}; fi; }
fi
# Processes metadata changes
export_meta "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} >${STDERR} 2>&1
[[ $? -eq 0 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#exportableidList[@]} ] Deployment of ${imageid} completed successfully"; }
[[ $? -eq 0 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#exportableidList[@]} ] Deployment of ${imageid} completed successfully"; if ${_DEBUG}; then cat ${STDERR}; fi; }
[[ $? -ne 0 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#exportableidList[@]} ] Application of metadata of ${imageid} completed with errors"; cat ${STDERR}; }
done

View file

@ -8,4 +8,5 @@ IFS='
'
_OPT_DB_FILE=.dam.db
_OPT_TMP=/tmp
_DEBUG=false

View file

@ -24,20 +24,24 @@ export_cp() {
## Splits IMAGEID into TRACKIDs
_msg EXEC "Splitting ${IMAGEID}"
gen_tracks "${GIT_DIR}" "${GIT_DIR}/${IMAGEID}.flac" "${GIT_DIR}/${IMAGEID}.cue" >${STDERR} 2>&1
[[ $? -ne 0 ]] && _msg WARN
local EXIT=$?
[[ ${EXIT} -ne 0 ]] && return 1
export_mv "${GIT_DIR}" ${IMAGEID} >${STDERR} 2>&1
[[ $? -eq 0 ]] && _msg OK || _msg WARN
local EXIT=$?
[[ ${EXIT} -ne 0 ]] && return 2
## Transfers selected TRACKIDs to TARGET
trackidList=($(awk -v imageid=${IMAGEID} 'BEGIN{FS="\t"}{if($1=="true" && $2==imageid && $4=="null"){print $3}}' "${DB_FILE}"))
for trackid in ${trackidList[@]}; do
_msg EXEC "Deploying ${trackid}"
cp "${GIT_DIR}/${IMAGEID}-${trackid}.flac" "${TARGET}/${IMAGEID}-${trackid}.flac"
if [[ $? -eq 0 ]]; then
local EXIT=$?
if [[ ${EXIT} -eq 0 ]]; then
_msg OK
gawk -i inplace -v trackid=${trackid} -v value="${IMAGEID}-${trackid}.flac" 'BEGIN{FS="\t";OFS="\t"}{if($3==trackid){$4=value}{print $0}}' ${DB_FILE}
else
_msg WARN
return 3
fi
done

View file

@ -16,6 +16,8 @@ gen_tracks() {
local IMAGE="${2}"
local CUE="${3}"
if [[ ! -f "${IMAGE}" ]] || [[ ! -f "${CUE}" ]]; then return 2; fi
## breakpointList generator
# Generates list with cuebreakpoints utility
local breakpointList=($(print_breakpoints "${CUE}" ))

View file

@ -36,6 +36,11 @@ while true; do
_FORCE="force"
;;
--debug)
_DEBUG=true
echo "Debug true"
;;
*)
break
;;