Skip to content

Commit e87567e

Browse files
Fix purge_paths in sync-r2.sh by removing unnecessary leading slashes (#178)
* Correct cut command in sync-r2.sh Fix cut command to use -c instead of --characters. * Remove backslash in purged file name * Quote purge_payload when echoing Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it> --------- Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
1 parent 0f517ee commit e87567e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sync-r2.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,18 @@ purge_paths=(
7474
"/soljson.js"
7575
)
7676
while IFS= read -r path; do
77-
purge_paths+=("/${path}")
78-
done < <(find . \( -wholename '*/list.*' -o -wholename '*/*-latest' -o -wholename '*/*-latest.*' \) | cut --characters 2-)
77+
purge_paths+=("${path}")
78+
done < <(find . \( -wholename '*/list.*' -o -wholename '*/*-latest' -o -wholename '*/*-latest.*' \) | cut -c 2-)
7979

8080
purge_payload="$(jq --null-input \
8181
--arg host "https://${cloudflare_cache_host}" \
8282
'{"files": ($ARGS.positional | map($host + .))}' \
8383
--args -- "${purge_paths[@]}"
8484
)"
8585

86+
# Print the payload to check purged files
87+
echo "$purge_payload"
88+
8689
curl --fail --show-error --silent \
8790
-X POST "https://api.cloudflare.com/client/v4/zones/${cloudflare_zone_id}/purge_cache" \
8891
-H "Authorization: Bearer ${cloudflare_api_token}" \

0 commit comments

Comments
 (0)