[gen_tracks][env][parser][cmd_export][export_cp] Added debug option and improved error handling
This commit is contained in:
parent
6f90cb5fb6
commit
45b2e27c31
5 changed files with 21 additions and 8 deletions
|
@ -58,7 +58,7 @@ cmd_export() {
|
||||||
for removableid in ${removableidList[@]}; do
|
for removableid in ${removableidList[@]}; do
|
||||||
echo "[ ${COUNT} / ${#removableidList[@]} ] Removing ${removableid}"
|
echo "[ ${COUNT} / ${#removableidList[@]} ] Removing ${removableid}"
|
||||||
export_rm "${TARGET}" "${DB_FILE}" ${removableid} >${STDERR} 2>&1
|
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 ))
|
local COUNT=$(( ${COUNT} + 1 ))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -75,18 +75,19 @@ cmd_export() {
|
||||||
local GIT_GET=true
|
local GIT_GET=true
|
||||||
[[ ${ERROR} -eq 255 ]] && git -C "${GIT_DIR}" annex get "${imageid}.flac" >/dev/null 2>&1
|
[[ ${ERROR} -eq 255 ]] && git -C "${GIT_DIR}" annex get "${imageid}.flac" >/dev/null 2>&1
|
||||||
local ERROR=$?
|
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
|
fi
|
||||||
export_cp "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} > ${STDERR} 2>&1
|
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
|
[[ "${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
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Processes metadata changes
|
# Processes metadata changes
|
||||||
export_meta "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} >${STDERR} 2>&1
|
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}; }
|
[[ $? -ne 0 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#exportableidList[@]} ] Application of metadata of ${imageid} completed with errors"; cat ${STDERR}; }
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
1
src/env
1
src/env
|
@ -8,4 +8,5 @@ IFS='
|
||||||
'
|
'
|
||||||
_OPT_DB_FILE=.dam.db
|
_OPT_DB_FILE=.dam.db
|
||||||
_OPT_TMP=/tmp
|
_OPT_TMP=/tmp
|
||||||
|
_DEBUG=false
|
||||||
|
|
||||||
|
|
|
@ -24,20 +24,24 @@ export_cp() {
|
||||||
## Splits IMAGEID into TRACKIDs
|
## Splits IMAGEID into TRACKIDs
|
||||||
_msg EXEC "Splitting ${IMAGEID}"
|
_msg EXEC "Splitting ${IMAGEID}"
|
||||||
gen_tracks "${GIT_DIR}" "${GIT_DIR}/${IMAGEID}.flac" "${GIT_DIR}/${IMAGEID}.cue" >${STDERR} 2>&1
|
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
|
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
|
## Transfers selected TRACKIDs to TARGET
|
||||||
trackidList=($(awk -v imageid=${IMAGEID} 'BEGIN{FS="\t"}{if($1=="true" && $2==imageid && $4=="null"){print $3}}' "${DB_FILE}"))
|
trackidList=($(awk -v imageid=${IMAGEID} 'BEGIN{FS="\t"}{if($1=="true" && $2==imageid && $4=="null"){print $3}}' "${DB_FILE}"))
|
||||||
for trackid in ${trackidList[@]}; do
|
for trackid in ${trackidList[@]}; do
|
||||||
_msg EXEC "Deploying ${trackid}"
|
_msg EXEC "Deploying ${trackid}"
|
||||||
cp "${GIT_DIR}/${IMAGEID}-${trackid}.flac" "${TARGET}/${IMAGEID}-${trackid}.flac"
|
cp "${GIT_DIR}/${IMAGEID}-${trackid}.flac" "${TARGET}/${IMAGEID}-${trackid}.flac"
|
||||||
if [[ $? -eq 0 ]]; then
|
local EXIT=$?
|
||||||
|
if [[ ${EXIT} -eq 0 ]]; then
|
||||||
_msg OK
|
_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}
|
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
|
else
|
||||||
_msg WARN
|
_msg WARN
|
||||||
|
return 3
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ gen_tracks() {
|
||||||
local IMAGE="${2}"
|
local IMAGE="${2}"
|
||||||
local CUE="${3}"
|
local CUE="${3}"
|
||||||
|
|
||||||
|
if [[ ! -f "${IMAGE}" ]] || [[ ! -f "${CUE}" ]]; then return 2; fi
|
||||||
|
|
||||||
## breakpointList generator
|
## breakpointList generator
|
||||||
# Generates list with cuebreakpoints utility
|
# Generates list with cuebreakpoints utility
|
||||||
local breakpointList=($(print_breakpoints "${CUE}" ))
|
local breakpointList=($(print_breakpoints "${CUE}" ))
|
||||||
|
|
|
@ -36,6 +36,11 @@ while true; do
|
||||||
_FORCE="force"
|
_FORCE="force"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
--debug)
|
||||||
|
_DEBUG=true
|
||||||
|
echo "Debug true"
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue