Skip to content

Commit 477f409

Browse files
committed
2022.08.09:
* fixed: bash/cache/accum-content.sh: missed to process forwarding backslash from the `md5sum` utility * changed: bash: support `TEMP_DIR` to be declared externally
1 parent c6dde21 commit 477f409

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

bash/board/accum-stats.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ jq_fix_null \
5959
[[ -z "$last_replies" || -n "${last_replies//[0-9]/}" ]] && last_replies=0
6060
[[ -z "$last_views" || -n "${last_views//[0-9]/}" ]] && last_views=0
6161

62-
TEMP_DIR="$(mktemp -d)"
62+
if [[ -z "$TEMP_DIR" ]]; then # otherwise use exterenal TEMP_DIR
63+
TEMP_DIR="$(mktemp -d)"
6364

64-
tkl_push_trap 'curl_print_response_if_error "$TEMP_DIR/response.txt"; rm -rf "$TEMP_DIR"' EXIT
65+
tkl_push_trap 'rm -rf "$TEMP_DIR"' EXIT
66+
fi
67+
68+
tkl_push_trap 'curl_print_response_if_error "$TEMP_DIR/response.txt"' EXIT
6569

6670
# CAUTION:
6771
# The `sed` has to be used to ignore blank lines by replacing `CR` by `LF`.

bash/cache/accum-content.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,15 @@ fi
168168
169169
content_index_file_prev_md5_hash=( $(md5sum -b "$content_index_file") )
170170
171-
TEMP_DIR="$(mktemp -d)"
171+
# drop forwarding backslash: https://unix.stackexchange.com/questions/424628/md5sum-prepends-to-the-checksum
172+
#
173+
content_index_file_prev_md5_hash="${content_index_file_prev_md5_hash#\\}"
174+
175+
if [[ -z "$TEMP_DIR" ]]; then # otherwise use exterenal TEMP_DIR
176+
TEMP_DIR="$(mktemp -d)"
172177
173-
tkl_push_trap 'rm -rf "$TEMP_DIR"' EXIT
178+
tkl_push_trap 'rm -rf "$TEMP_DIR"' EXIT
179+
fi
174180
175181
stats_failed_inc=0
176182
stats_skipped_inc=0
@@ -292,6 +298,10 @@ for i in $("${YQ_CMDLINE_READ[@]}" '."content-config".entries[0].dirs|keys|.[]'
292298
if (( is_index_file_prev_exist )); then
293299
# to update the file hash in the index file
294300
index_file_next_md5_hash=( $(md5sum -b "$index_dir/$index_file") )
301+
302+
# drop forwarding backslash: https://unix.stackexchange.com/questions/424628/md5sum-prepends-to-the-checksum
303+
#
304+
index_file_next_md5_hash="${index_file_next_md5_hash#\\}"
295305
fi
296306
297307
if (( ! is_file_expired )); then
@@ -393,6 +403,10 @@ for i in $("${YQ_CMDLINE_READ[@]}" '."content-config".entries[0].dirs|keys|.[]'
393403
394404
index_file_next_md5_hash=( $(md5sum -b "$TEMP_DIR/content/$index_dir/$index_file") )
395405
406+
# drop forwarding backslash: https://unix.stackexchange.com/questions/424628/md5sum-prepends-to-the-checksum
407+
#
408+
index_file_next_md5_hash="${index_file_next_md5_hash#\\}"
409+
396410
if [[ "$index_file_next_md5_hash" != "$index_file_prev_md5_hash" ]]; then
397411
echo "File MD5 hash is changed: new=\`$index_file_next_md5_hash\` prev=\`$index_file_prev_md5_hash\`"
398412
else
@@ -441,6 +455,10 @@ done
441455
442456
content_index_file_next_md5_hash=( $(md5sum -b "$content_index_file") )
443457
458+
# drop forwarding backslash: https://unix.stackexchange.com/questions/424628/md5sum-prepends-to-the-checksum
459+
#
460+
content_index_file_next_md5_hash="${content_index_file_next_md5_hash#\\}"
461+
444462
if (( stats_changed_inc )) || [[ "$content_index_file_next_md5_hash" != "$content_index_file_prev_md5_hash" ]]; then
445463
{
446464
# update index file change timestamp

bash/github/init-curl-workflow.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ SOURCE_GHWF_INIT_CURL_WORKFLOW_SH=1 # including guard
1616

1717
source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?
1818

19+
tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-basic-workflow.sh"
20+
1921

2022
function curl_print_response_if_error()
2123
{
24+
if [[ -z "$TEMP_DIR" ]]; then # otherwise use exterenal TEMP_DIR
25+
TEMP_DIR="$(mktemp -d)"
26+
27+
tkl_push_trap 'rm -rf "$TEMP_DIR"' RETURN
28+
fi
29+
2230
local last_error=$?
2331
local response_file="${1:-"$TEMP_DIR/response.txt"}"
2432

bash/inpage/accum-downloads.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ IFS=$'\n' read -r -d '' last_downloads <<< "$(jq -c -r ".downloads" $stats_json)
4949
jq_fix_null \
5050
last_downloads:0
5151

52-
TEMP_DIR="$(mktemp -d)"
52+
if [[ -z "$TEMP_DIR" ]]; then # otherwise use exterenal TEMP_DIR
53+
TEMP_DIR="$(mktemp -d)"
5354

54-
tkl_push_trap 'curl_print_response_if_error "$TEMP_DIR/response.txt"; rm -rf "$TEMP_DIR"' EXIT
55+
tkl_push_trap 'rm -rf "$TEMP_DIR"' EXIT
56+
fi
57+
58+
tkl_push_trap 'curl_print_response_if_error "$TEMP_DIR/response.txt"' EXIT
5559

5660
# CAUTION:
5761
# The `sed` has to be used to ignore blank lines by replacing `CR` by `LF`.

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2022.08.09:
2+
* fixed: bash/cache/accum-content.sh: missed to process forwarding backslash from the `md5sum` utility
3+
* changed: bash: support `TEMP_DIR` to be declared externally
4+
15
2022.08.08:
26
* fixed: bash/github/init-yq-workflow.sh: `yq_restore_edited_uniform_diff` inaccurate blank lines position
37

0 commit comments

Comments
 (0)