3 # A simple Bash script to delete an media from the Nginx cache.
7 # NGINX cache directory
8 CACHE_DIRECTORY
="/tmp/pleroma-media-cache"
10 function get_cache_files
() {
11 local max_parallel
=${3-16}
12 find $2 -maxdepth 1 -type d
| xargs -P $max_parallel -n 1 grep -ERl "^KEY:.*$1" | sort -u
15 function purge_item
() {
17 cache_files
=$(get_cache_files "$1" "$2")
19 if [ -n "$cache_files" ]; then
20 for i
in $cache_files; do
22 echo "Deleting $i from $2."
26 echo "$1 is not cached."
33 echo "$SCRIPTNAME delete $url from cache ($CACHE_DIRECTORY)"
34 purge_item
$url $CACHE_DIRECTORY