From 956a8c8506a36a9d32787101fd6577d5d1e58b95 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 17 Sep 2022 22:13:30 +0200 Subject: [PATCH] purge CF cache on emoji update --- files/routes/asset_submissions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index b4de9f84e..98c15f4e5 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -377,11 +377,18 @@ def update_marsey(v): highquality = f"/asset_submissions/marseys/{name}" file.save(highquality) with Image.open(highquality) as i: - new_path = f'/asset_submissions/marseys/original/{name}.{i.format.lower()}' + format = i.format.lower() + new_path = f'/asset_submissions/marseys/original/{name}.{format}' rename(highquality, new_path) filename = f"files/assets/images/emojis/{name}.webp" copyfile(new_path, filename) process_image(filename, resize=250, trim=True) + x = requests.post(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache', headers=CF_HEADERS, + data=f'{{"files": ["https://{SITE}/e/{name}.webp", "https://{SITE}/assets/images/emojis/{name}.webp", "https://{SITE}/asset_submissions/marseys/original/{name}.{format}"]}}', timeout=5) + + print(x, flush=True) + print(x.text, flush=True) + return render_template("update_marseys.html", v=v, msg=f"'{name}' updated successfully!") \ No newline at end of file