dam/src/chk_metadata

31 lines
1.1 KiB
Bash

#!/bin/bash
# doc chk_metadata {
#
# DESCRIPTION
# chk_metadata - Checks metadata of TRACKIDs in TARGET
#
# USAGE
# chk_metadata </path/to/git/dir> </path/to/target> </path/to/db/file> [<IMAGEID>] [<...>]
#
# DEPENDENCIES bunc/src/* src/export_meta
#
# }
chk_metadata() {
local GIT_DIR="${1}"
local TARGET="${2}"
local DB_FILE="${3}"; shift 3
local imageidList=(${@})
[[ -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
echo "[ ${COUNT} / ${#imageidList[@]} ] Checking ${imageid} in ${TARGET}"
export_meta "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} >${STDERR} 2>&1
[[ $? -eq 0 ]] || { echo "[>>>>>>] Error reported"; cat ${STDERR}; local ERR=true; }
local COUNT=$(( ${COUNT} + 1 ))
done
[[ "${ERR}" == "true" ]] && { _msg EXEC "Metadata check completed with errors"; _msg WARN; } || { _msg EXEC "Metadata check completed succesfully"; _msg OK; }
}