Skip to content

Commit

Permalink
Fixed upload error behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
monochromec committed Oct 9, 2023
1 parent 0d308f9 commit af0c315
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions migrate_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,20 +271,24 @@ async def post_event(self, room: nio.MatrixRoom, event: nio.Event) -> None:
resp, _ = await self.client.upload(data_provider=io.BytesIO(body), content_type=mime,
filename=name, filesize=body_size)

if self.verb:
if isinstance(resp, nio.UploadResponse):
if isinstance(resp, nio.UploadResponse):
if self.verb:
sys_exit(f'Uploaded {name}, obtained URL {resp.content_uri}', False)
else:
sys_exit(f'Error when uploading {name}: {str(resp)}', False)

content = {
'body': name,
'info': {
'size': body_size,
'mimetype': mime,
},
'url': resp.content_uri
}
content = {
'body': name,
'info': {
'size': body_size,
'mimetype': mime,
},
'url': resp.content_uri
}

else:
err_str = str(resp)
sys_exit(f'Error when uploading {name}: {err_str}', False)
content = {
'body': err_str
}
else:
content = {
'body': 'Empty body, something went wrong'
Expand Down

0 comments on commit af0c315

Please sign in to comment.