[parser][cmd_fsck][chk_duplicate_trackid] Added function to check for duplicate trackids
This commit is contained in:
parent
ada07ad3a9
commit
db443fa032
3 changed files with 34 additions and 1 deletions
24
src/chk_duplicate_trackid
Normal file
24
src/chk_duplicate_trackid
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
chk_duplicate_trackid() {
|
||||||
|
local DB_FILE="${1}"
|
||||||
|
shift
|
||||||
|
local trackidList=(${@})
|
||||||
|
[ -z ${trackidList+x} ] && local trackidList=($(awk 'BEGIN{FS="\t"}{print $3}' ${DB_FILE} | awk '!seen[$0]++'))
|
||||||
|
|
||||||
|
local COUNT=1
|
||||||
|
for trackid in ${trackidList[@]}; do
|
||||||
|
echo "[ ${COUNT} / ${#trackidList[@]} ] Checking duplicate ${trackid} in ${DB_FILE}"
|
||||||
|
local curtrackidList=($(awk -v trackid=${trackid} 'BEGIN{FS="\t"}{if($3==trackid){print $3}}' ${DB_FILE}))
|
||||||
|
if [[ ${#curtrackidList[@]} -gt 1 ]]; then
|
||||||
|
_ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#trackidList[@]} ] ${trackid} duplicate"
|
||||||
|
local duplicatetrackidList=(${duplicatetrackidList[@]} ${trackid})
|
||||||
|
local ERR=true
|
||||||
|
else
|
||||||
|
_ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#trackidList[@]} ] ${trackid} not duplicate"
|
||||||
|
fi
|
||||||
|
local COUNT=$(( ${COUNT} + 1 ))
|
||||||
|
done
|
||||||
|
printf "Duplicate track: %s\n" ${duplicatetrackidList[@]} > ${STDERR}
|
||||||
|
[[ "${ERR}" == "true" ]] && { _msg EXEC "Duplicate trackid check completed with errors"; _msg WARN; } || { _msg EXEC "Duplicate trackid check completed succesfully"; _msg OK; }
|
||||||
|
}
|
|
@ -34,6 +34,10 @@ cmd_fsck() {
|
||||||
metadata)
|
metadata)
|
||||||
chk_metadata "${GIT_DIR}" "${TARGET}" "${DB_FILE}"
|
chk_metadata "${GIT_DIR}" "${TARGET}" "${DB_FILE}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
duplicate-trackid)
|
||||||
|
chk_duplicate_trackid "${DB_FILE}"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,6 +176,11 @@ case "${1}" in
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
--duplicate-trackid)
|
||||||
|
cmdList=(${cmdList[@]} duplicate-trackid)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
TARGET="${1}"
|
TARGET="${1}"
|
||||||
shift
|
shift
|
||||||
|
@ -184,7 +189,7 @@ case "${1}" in
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ -z ${cmdList[@]} ]] && cmdList=(deployed-ids nonexistent-ids metadata)
|
[[ -z ${cmdList[@]} ]] && cmdList=(deployed-ids nonexistent-ids metadata duplicate-trackid)
|
||||||
|
|
||||||
cmd_fsck "${_GIT_DIR}" "${TARGET}" ${cmdList[@]}
|
cmd_fsck "${_GIT_DIR}" "${TARGET}" ${cmdList[@]}
|
||||||
EXIT=$?
|
EXIT=$?
|
||||||
|
|
Loading…
Reference in a new issue