Manually handle deleting file

This commit is contained in:
Nexus 2024-04-14 23:24:17 +01:00
parent 8d7cee3e89
commit 47ff9f6110
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -66,7 +66,7 @@ class AutoResponder(commands.Cog):
else:
self.log.info("No HEVC streams found in %s", uri)
return
with tempfile.NamedTemporaryFile(suffix=".mp4") as tmp:
with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False, delete_on_close=False) as tmp:
tmp_path = pathlib.Path(tmp.name)
self.log.info("Transcoding %r to %r", uri, tmp_path)
args = [
@ -119,6 +119,7 @@ class AutoResponder(commands.Cog):
_p,
_p.stat().st_size / 1024 / 1024
)
_p.unlink()
except Exception as e:
self.log.error("Failed to transcode %r: %r", link, e)