fix: Handle malformed previous_defed.json

main
db0 2024-05-04 14:07:41 +02:00
parent 3b80a4043e
commit f5850e8cc7
1 changed files with 2 additions and 1 deletions

View File

@ -82,7 +82,8 @@ defed = (set(blocklist) | set(trusted_censures["domains"]) | set(filtered_censur
try: try:
with open("previous_defed.json", 'r') as file: with open("previous_defed.json", 'r') as file:
prev_defed = set(json.loads(file.read())) prev_defed = set(json.loads(file.read()))
except FileNotFoundError: except (FileNotFoundError,json.decoder.JSONDecodeError):
print("WARNING: Previous defed file doesn't exist. Will probably receive a warning about blocklist.")
prev_defed = set() prev_defed = set()
if len(defed - prev_defed) > 0: if len(defed - prev_defed) > 0:
print(f"New blocks to add {defed - prev_defed}") print(f"New blocks to add {defed - prev_defed}")