Better compress status

This commit is contained in:
nexy7574 2023-05-11 19:01:53 +01:00
parent eab3b5871c
commit 03743e2f65

View file

@ -1264,6 +1264,7 @@ class OtherCog(commands.Cog):
embed.description += f"\N{warning sign}\ufe0f {file.name} is empty.\n" embed.description += f"\N{warning sign}\ufe0f {file.name} is empty.\n"
continue continue
st = file.stat().st_size st = file.stat().st_size
COMPRESS_FAILED = False
if st / 1024 / 1024 >= MAX_SIZE_MB or st >= BYTES_REMAINING: if st / 1024 / 1024 >= MAX_SIZE_MB or st >= BYTES_REMAINING:
if compress_if_possible: if compress_if_possible:
await ctx.edit( await ctx.edit(
@ -1297,7 +1298,7 @@ class OtherCog(commands.Cog):
) )
) )
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
pass COMPRESS_FAILED = True
else: else:
file = target file = target
st = file.stat().st_size st = file.stat().st_size
@ -1311,11 +1312,12 @@ class OtherCog(commands.Cog):
st_r /= 1024 st_r /= 1024
units.pop(0) units.pop(0)
embed.description += "\N{warning sign}\ufe0f {} is too large to upload ({!s}{}" \ embed.description += "\N{warning sign}\ufe0f {} is too large to upload ({!s}{}" \
", max is {}MB).\n".format( ", max is {}MB{}).\n".format(
file.name, file.name,
round(st_r, 2), round(st_r, 2),
units[0], units[0],
MAX_SIZE_MB MAX_SIZE_MB,
', compressing failed' if COMPRESS_FAILED else ''
) )
continue continue
else: else: