remove all previous high quality versions of an asset when updating it

master
Aevann1 2022-09-19 01:34:23 +02:00
parent 2050c554e3
commit 0930f85c4b
1 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,5 @@
from shutil import move, copyfile
from os import listdir, rename
from os import listdir, rename, path
from files.__main__ import app, limiter
from files.helpers.const import *
@ -373,6 +373,9 @@ def update_marsey(v):
if not existing:
return error("A marsey with this name doesn't exist!")
for x in ('png','jpg','jpeg','webp','gif'):
if path.isfile(f'/asset_submissions/marseys/original/{name}.{x}'):
os.remove(f'/asset_submissions/marseys/original/{name}.{x}')
highquality = f"/asset_submissions/marseys/{name}"
file.save(highquality)
@ -431,6 +434,11 @@ def update_hat(v):
format = i.format.lower()
new_path = f'/asset_submissions/hats/original/{name}.{format}'
for x in ('png','jpg','jpeg','webp','gif'):
if path.isfile(f'/asset_submissions/hats/original/{name}.{x}'):
os.remove(f'/asset_submissions/hats/original/{name}.{x}')
rename(highquality, new_path)
filename = f"files/assets/images/hats/{name}.webp"