5f6cbb128344b636006baf01c96d0bf567253a85
3 # A simple shell script to delete a media from the Nginx cache.
7 # NGINX cache directory
8 CACHE_DIRECTORY
="/tmp/pleroma-media-cache"
10 ## Return the files where the items are cached.
11 ## $1 - the filename, can be a pattern .
12 ## $2 - the cache directory.
13 ## $3 - (optional) the number of parallel processes to run for grep.
15 local max_parallel
=${3-16}
16 find $2 -maxdepth 2 -type d
| xargs -P $max_parallel -n 1 grep -E -Rl "^KEY:.*$1" | sort -u
19 ## Removes an item from the given cache zone.
20 ## $1 - the filename, can be a pattern .
21 ## $2 - the cache directory.
23 for f
in $(get_cache_files $1 $2); do
26 echo "Deleting $f from $2."
34 echo "$SCRIPTNAME delete \`$url\` from cache ($CACHE_DIRECTORY)"
35 purge_item
$url $CACHE_DIRECTORY