russelldavies / matrix-archive

Archive Matrix room messages
Apache License 2.0
95 stars 17 forks source link

Continue with next room when one crashes #25

Open laolux opened 3 years ago

laolux commented 3 years ago

I have at least one room on my matrix server where matrix-archive consistently crashes. I tried to re-export my keys and stuff, but to no avail. It would be awesome if matrix-archive would simply continue with the next room or return to the room selection screen when a crash occurs.

Attached a redacted output from the crash:

Enter room id: !roomid:example.com
Fetching !roomid:example.com room messages and writing to disk...
Traceback (most recent call last):
  File "./matrix-archive.py", line 401, in <module>
    asyncio.get_event_loop().run_until_complete(main())
  File "/usr/lib64/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "./matrix-archive.py", line 387, in main
    await write_room_events(client, room)
  File "./matrix-archive.py", line 342, in write_room_events
    async with aiofiles.open(filename, "wb") as f_media:
  File "/home/user/matrix-archive/venv/lib64/python3.8/site-packages/aiofiles/base.py", line 78, in __aenter__
    self._obj = yield from self._coro
  File "/home/user/matrix-archive/venv/lib64/python3.8/site-packages/aiofiles/threadpool/__init__.py", line 35, in _open
    f = yield from loop.run_in_executor(executor, cb)
  File "/usr/lib64/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
FileNotFoundError: [Errno 2] No such file or directory: 'user_matrix_backup_20210203_new2/user WhatsApp bridge bot_!roomid:example.com_media/abc/def,ghi,klm'

The behavior is very reliable, i.e. it crashes on this room every time. Other rooms with more messages and media download just fine. Any suggestions how I could help to debug this problem are welcome.

russelldavies commented 3 years ago

Looks related to #26 where a slash in media filenames breaks writing.