clean up on error
This commit is contained in:
parent
265471864f
commit
72dff170ca
|
@ -1,6 +1,7 @@
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
@ -112,6 +113,9 @@ class MatrixBotCallbacks:
|
||||||
return
|
return
|
||||||
|
|
||||||
zipfile_name = f'{room.room_id.replace(":", "_").replace("!", "").replace(".", "")}-{int(time.time())}.zip'
|
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(
|
start_msg = await self.client.room_send(
|
||||||
room_id=room.room_id,
|
room_id=room.room_id,
|
||||||
message_type="m.room.message",
|
message_type="m.room.message",
|
||||||
|
@ -200,3 +204,7 @@ class MatrixBotCallbacks:
|
||||||
'm.room.message',
|
'm.room.message',
|
||||||
content
|
content
|
||||||
)
|
)
|
||||||
|
if zipfile_path:
|
||||||
|
os.remove(zipfile_path)
|
||||||
|
if temp_dir:
|
||||||
|
shutil.rmtree(temp_dir)
|
||||||
|
|
Loading…
Reference in New Issue