From 273bcbcb8f4c4dce3cc29d2c68dee92fb137f23c Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Sun, 18 Jul 2021 09:07:15 +0200 Subject: [PATCH] fix cache busting --- setup-scripts/blocklist-airtable.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/setup-scripts/blocklist-airtable.py b/setup-scripts/blocklist-airtable.py index a7773cee..eb835955 100755 --- a/setup-scripts/blocklist-airtable.py +++ b/setup-scripts/blocklist-airtable.py @@ -96,20 +96,22 @@ async def block_skylinks_from_airtable(): return await send_msg(message, force_notify=False) print("Searching nginx cache for blocked files") - cached_files_count = 0 + total_cached_files_count = 0 for i in range(0, len(skylinks), 1000): cached_files_command = ( - "find /data/nginx/cache/ -type f | xargs --no-run-if-empty -n1000 grep -Els '^Skynet-Skylink: .*(" + "find /data/nginx/cache/ -type f | xargs --no-run-if-empty -n1000 grep -Els '^Skynet-Skylink: (" + "|".join(skylinks[i:i+1000]) + ")'" ) - cached_files_count += int(exec('docker exec -it nginx bash -c "' + cached_files_command + ' | wc -l"') or 0) + cached_files_count = int(exec('docker exec -it nginx bash -c "' + cached_files_command + ' | wc -l"') or 0) + if cached_files_count: + total_cached_files_count+= cached_files_count + exec('docker exec -it nginx bash -c "' + cached_files_command + ' | xargs rm"') - if cached_files_count == 0: + if total_cached_files_count == 0: return print("No nginx cached files matching blocked skylinks were found") - exec('docker exec -it nginx bash -c "' + cached_files_command + ' | xargs rm"') - message = "Purged " + str(cached_files_count) + " blocklisted files from nginx cache" + message = "Purged " + str(total_cached_files_count) + " blocklisted files from nginx cache" return await send_msg(message)