Add comments to nginx pruning script

This commit is contained in:
Filip Rysavy 2021-12-06 14:13:56 +01:00
parent 0af14d32db
commit aca71c245e
No known key found for this signature in database
GPG Key ID: EA1F430401C92D99
1 changed files with 6 additions and 0 deletions

View File

@ -9,10 +9,16 @@ MAX_KEEP_FILE_SIZE=1000000000
total=0
# We sort files by time, newest files are first. Format is:
# time (last modification as seconds since Epoch), filepath, size (bytes)
find /home/user/skynet-webportal/docker/data/nginx/cache -type f -exec stat -c "%Y %n %s" {} + | sort -rgk1 | while read line
do
size=$(echo $line | awk '{print $3}')
new_total=$(($total + $size))
# We always delete all files larger than MAX_KEEP_FILE_SIZE.
# We keep all files smaller than MAX_KEEP_FILE_SIZE when cache size is
# below MAX_CACHE_DIR_SIZE, then we delete also smaller files.
if (("$size" <= "$MAX_KEEP_FILE_SIZE" && "$total" < "$new_total"))
then
total=$new_total