[chk_metadata] [cmd_deploy] [deploy_meta] Added prettier CLI logging

This commit is contained in:
ayakael 2018-04-07 17:09:22 -04:00
parent 3e6cec87fd
commit d65b85be8f
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026
3 changed files with 25 additions and 11 deletions

View file

@ -18,10 +18,11 @@ chk_metadata() {
[[ -z "${imageidList[@]}" ]] && local imageidList=($(awk 'BEGIN{FS="\t"}{if($1=="true" && $4!="null"){print $2}}' "${DB_FILE}" | awk '!seen[$0]++'))
local COUNT=1
for imageid in ${imageidList[@]}; do
_msg EXEC "Checking ${imageid}"
echo "[ ${COUNT} / ${#imageidList[@]} ] Checking ${imageid} in ${TARGET}"
deploy_meta "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} >${STDERR} 2>&1
[[ $? -eq 0 ]] && _msg OK || _msg WARN
[[ $? -eq 0 ]] && { _ansi up 2; echo -en '\033[K'; } || { echo "[>>>>>>] Error reported"; cat ${STDERR}; local ERR=true; }
local COUNT=$(( ${COUNT} + 1 ))
done
}

View file

@ -13,6 +13,7 @@
cmd_deploy() {
local GIT_DIR="${1}"
local TARGET="${2}"; shift 2
local ERR=false
local DB_FILE="${TARGET}/${_OPT_DB_FILE}"
[[ ! -f "${DB_FILE}" ]] && return 1
@ -35,19 +36,30 @@ cmd_deploy() {
[[ ${DU} -ge ${DF} ]] && { _msg ECHO "Target does not have enough space for deployable IMAGEID. Need ${DU}, has ${DF}."; return 2; }
# Cleans target of removable TRACKID
local COUNT=1
for removableid in ${removableidList[@]}; do
deploy_rm "${TARGET}" "${DB_FILE}" ${removableid}
echo "[ ${COUNT} / ${#removableidList[@]} ] Removing ${removableid} from ${TARGET}"
deploy_rm "${TARGET}" "${DB_FILE}" ${removableid} >${STDERR} 2>&1
[[ $? -eq 0 ]] && { _ansi up 2; echo -en '\033[K'; } || { echo "[>>>>>>] Error reported"; cat ${STDERR}; local ERR=true; }
local COUNT=$(( ${COUNT} + 1 ))
done
local COUNT=0
for imageid in ${updateableidList[@]}; do
local COUNT=$(( ${COUNT} + 1 ))
echo "[ ${COUNT} / ${#updateableidList[@]} ] Deploying ${imageid} to ${TARGET}"
# Processes deployableids (IMAGEIDs that have TRACKIDs that are not present in target, but are selected)
if _if_array_contains ${imageid} ${deployableidList[@]}; then
deploy_cp "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid}
deploy_cp "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} > ${STDERR} 2>&1
[[ $? -eq 0 ]] || { echo "[>>>>>>] Error reported"; cat ${STDERR}; local ERR=true; continue; }
fi
# Processed metadata changes
deploy_meta "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid}
# Processes metadata changes
deploy_meta "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} >${STDERR} 2>&1
[[ $? -eq 0 ]] && { _ansi up 2; echo -en '\033[K'; } || { echo "[>>>>>>] Error reported"; cat ${STDERR}; local ERR=true; }
done
[[ ${ERR} ]] && return 1 || { gawk -i inplace -v newcommit=${NEW_COMMIT} 'BEGIN{FS="\t";OFS="\t"}{if($1=="LAST_DEPLOY"){$2=newcommit}{print $0}}' ${DB_FILE}; return 0; }
[[ "${ERR}" == "true" ]] && return 1 || { gawk -i inplace -v newcommit=${NEW_COMMIT} 'BEGIN{FS="\t";OFS="\t"}{if($1=="LAST_DEPLOY"){$2=newcommit}{print $0}}' ${DB_FILE}; return 0; }
}

View file

@ -30,19 +30,20 @@ deploy_meta() {
# If the PRESENT_META and FUTURE_META diverge, wipe the old metadata, and reapply
if [[ "${PRESENT_META}" != "${FUTURE_META}" ]]; then
local ERR=true
_msg ECHO "${trackid} has differing metadata. Updating"
[[ "${PRESENT_PATH}" == "null" ]] || metaflac --remove-all "${TARGET}/${PRESENT_PATH}"
awk 'BEGIN {RS=";"}{print $0}' <<< ${FUTURE_META} | head -n -1 | metaflac --import-tags-from=- --import-picture-from="${GIT_DIR}/${IMAGEID}.jpg" "${TARGET}/${PRESENT_PATH}"
[[ $? -eq 0 ]] || local ERR=true
fi
# If the PRESENT_PATH and FUTURE_PATH diverge, move to new location
if [[ "${PRESENT_PATH}" != "${FUTURE_PATH}" ]]; then
local ERR=true
_msg ECHO "${trackid} has differing paths. Moving"
mkdir -p "$(dirname "${TARGET}/${FUTURE_PATH}")"
[[ $? -eq 0 ]] || local ERR=true
mv "${TARGET}/${PRESENT_PATH}" "${TARGET}/${FUTURE_PATH}"
rmdir -p --ignore-fail-on-non-empty "$(dirname "${TARGET}/${PRESENT_PATH}")" >${STDERR} 2>&1
[[ $? -eq 0 ]] || local ERR=true
rmdir -p --ignore-fail-on-non-empty "$(dirname "${TARGET}/${PRESENT_PATH}")" >/dev/null 2>&1
gawk -i inplace -v trackid=${trackid} -v value="${FUTURE_PATH}" 'BEGIN{FS="\t";OFS="\t"}{if($3==trackid){$4=value}{print $0}}' ${DB_FILE}
fi
done