[db_update] Fixed bug with detection of deleted IMAGEIDs in git directory-side, and reporting in database file
[db_update] Now exits with specific code per possibility for IMAGEID (if added, exit code 0, if removed, exit code 1) [cmd_update] Depending on exit code from db_update, echoes message now
This commit is contained in:
parent
a5b5b27426
commit
f08dcd417b
2 changed files with 7 additions and 7 deletions
|
@ -33,7 +33,9 @@ cmd_update() {
|
|||
for imageid in ${imageidList[@]}; do
|
||||
echo "[ ${COUNT} / ${#imageidList[@]} ] Processing ${imageid}"
|
||||
db_update "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageid} >${STDERR} 2>&1
|
||||
[[ $? -eq 0 ]] || { echo "[>>>>>>] Error reported"; cat ${STDERR}; local ERR=true; }
|
||||
local EXIT=$?
|
||||
[[ ${EXIT} -eq 0 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#imageidList[@]} ] Added ${imageid}"; }
|
||||
[[ ${EXIT} -eq 1 ]] && { _ansi up 2; echo -en '\033[K'; echo "[ ${COUNT} / ${#imageidList[@]} ] Removed ${imageid}"; }
|
||||
local COUNT=$(( ${COUNT} + 1 ))
|
||||
done
|
||||
[[ ${ERR} ]] && return 1 || { gawk -i inplace -v newcommit=${NEW_COMMIT} 'BEGIN{FS="\t";OFS="\t"}{if($1=="LAST_UPDATE"){$2=newcommit}{print $0}}' ${DB_FILE}; return 0; }
|
||||
|
|
|
@ -18,16 +18,14 @@ db_update() {
|
|||
|
||||
[[ -f "${DB_FILE}" ]] || touch "${DB_FILE}"
|
||||
trackidList=($(awk 'BEGIN{FS="\" : \"";RS="\",\n * \""}{if($1=="TRACKID"){print $2}}' ${GIT_DIR}/${IMAGEID}.tags))
|
||||
if [[ ! -f ${GIT_DIR}/${IMAGEID}.tags ]]; then
|
||||
_msg ECHO "Removing ${IMAGEID} from database file"
|
||||
gawk -i inplace -v imageid="${IMAGEID}" 'BEGIN{FS="\t";OFS="\t"}{if($2=imageid){$1="null"}{print $0}}' ${DB_FILE}
|
||||
continue
|
||||
if [[ ! -f "${GIT_DIR}/${IMAGEID}.tags" ]]; then
|
||||
gawk -i inplace -v imageid="${IMAGEID}" 'BEGIN{FS="\t";OFS="\t"}{if($2==imageid){$1="null"}{print $0}}' ${DB_FILE}
|
||||
return 1
|
||||
fi
|
||||
for trackid in ${trackidList[@]}; do
|
||||
if [[ -z $(awk -v imageid="${IMAGEID}" -v trackid="${trackid}" 'BEGIN{FS="\t"}{if($2==imageid && $3==trackid){print $0}}' ${DB_FILE}) ]]; then
|
||||
_msg ECHO "Adding ${trackid} of ${IMAGEID} to database file"
|
||||
echo -e "true\t${IMAGEID}\t${trackid}\tnull" >> ${DB_FILE}
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
done
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue