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)