[cmd_update] Now updates DB_FILE with new commit hash when database update success

This commit is contained in:
ayakael 2018-03-29 09:24:58 -04:00
parent df69dbe70e
commit a22a2d1575
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026

View file

@ -30,5 +30,5 @@ cmd_update() {
_msg EXEC "Updating database from ${OLD_COMMIT} to ${NEW_COMMIT}"
db_update "${GIT_DIR}" "${TARGET}" "${DB_FILE}" ${imageidList[@]}
[[ $? -ne 0 ]] && { _msg WARN; local ERR=true; } || _msg OK
[[ ${ERR} ]] && return 1 || return 0
[[ ${ERR} ]] && return 1 || { awk -v newcommit=${NEW_COMMIT} 'BEGIN{FS="\t"}{if($1=="LAST_COMMIT"){$2=newcommit}{print $0}}' ${DB_FILE} > ${DB_FILE}.tmp; mv ${DB_FILE}.tmp ${DB_FILE}; return 0; }
}