diff --git a/exporter/callbacks.py b/exporter/callbacks.py index dd43c03..df5f85e 100644 --- a/exporter/callbacks.py +++ b/exporter/callbacks.py @@ -1,6 +1,7 @@ import copy import json import logging +import os import shutil import tempfile import time @@ -112,6 +113,9 @@ class MatrixBotCallbacks: return zipfile_name = f'{room.room_id.replace(":", "_").replace("!", "").replace(".", "")}-{int(time.time())}.zip' + zipfile_path = None + temp_dir = None + start_msg = await self.client.room_send( room_id=room.room_id, message_type="m.room.message", @@ -200,3 +204,7 @@ class MatrixBotCallbacks: 'm.room.message', content ) + if zipfile_path: + os.remove(zipfile_path) + if temp_dir: + shutil.rmtree(temp_dir)