Closed Thinkscape closed 2 years ago
You can catch ClientError
s, the type
attribute of the exception will be NotTorrent
. However, it is better to prevent uploading of non-torrent files in the first place.
Nice. Thanks for a quick fix @cenkalti. A file being a torrent or not might not always be obvious, or put.io might not like the input on the backend, hence the requirement.
On the automator side we will still need to catch it, as the "torrent" directory can potentially contain some non-torrent files (for whatever reason). Current behaviour is a crash of the whole watcher process (command). IMO it should catch and continue with remaining files in such case.
I am testing a hotfix which adds a try/except wrapper around the handler so that it does not crash the thread. https://pypi.org/project/putio-automator/2.0.1.dev4/ This will become version 2.0.1 when released.
Running docker container:
It seems that this will happen if the file provided to automator is not a torrent file or otherwise is rejected by put.io (does not result in a new transfer being created).
The error originates in
putiopy
where they just try to returntransfer
from put.io response JSON, but the docs state it's optional:I guess automator could catch that as well, as it's the point of origin for calling
add_torrent
and should react better to files being rejected.