Skip to content

Commit

Permalink
add debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Oct 23, 2024
1 parent 52fdbd1 commit 77aaa5f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions bin/digifeeds/upload_to_s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ log_info() {
log_error() {
echo "$(date --rfc-3339=seconds) - ERROR: ${@}"
}
log_debug()
{
[[ ${DEBUG:-false} == "true" ]] && echo "$(date --rfc-3339=seconds) - DEBUG: ${@}"
}

# Gets the last count from a job in the push gateway push gateway
last_count() {
Expand Down Expand Up @@ -136,7 +140,7 @@ main() {

log_info "Copying $barcode"

log_info "Verifying image order $barcode"
log_debug "Verifying image order $barcode"
#8 digits, ends in .tif or .jp2
filter_regex='[[:digit:]]{8}\.tif$|[[:digit:]]{8}\.jp2$'
local image_list=$(cd $barcode_path && ls | egrep "$filter_regex")
Expand All @@ -149,23 +153,23 @@ main() {
fi


log_info "Zipping $barcode"
log_debug "Zipping $barcode"
zip_it $input_directory/$barcode
if [[ $? != 0 ]]; then
log_error "Failed to zip $barcode"
errors_total=$((errors_total + 1))
continue
fi

log_info "Verifying zip of $barcode"
log_debug "Verifying zip of $barcode"
verify_zip $input_directory/$barcode
if [[ $? != 0 ]]; then
log_error "$barcode.zip does not contain the correct files"
errors_total=$((errors_total + 1))
continue
fi

log_info "Sending $barcode to S3"
log_debug "Sending $barcode to S3"
rclone copy $input_directory/$barcode.zip $digifeeds_bucket:
if [[ $? != 0 ]]; then
log_error "Failed to copy $barcode"
Expand All @@ -174,7 +178,7 @@ main() {
continue
fi

log_info "Verifying barcode in S3"
log_debug "Verifying barcode in S3"
rclone check $input_directory/$barcode.zip $digifeeds_bucket:
if [[ $? != 0 ]]; then
log_error "$barcode not found in S3"
Expand Down

0 comments on commit 77aaa5f

Please sign in to comment.