Skip to content

Commit

Permalink
Merge pull request #7203 from xoriole/fix/torrentinfo-file-not-found
Browse files Browse the repository at this point in the history
Handle non-existing file in torrent info endpoint
  • Loading branch information
xoriole authored Nov 25, 2022
2 parents 2b4710b + c35973c commit 3653f9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def verify_valid_dict(json_data):
# Corrupt file
await do_request(rest_api, url, params={'uri': _path('test_rss.xml')}, expected_code=500)

# Non-existing file
await do_request(rest_api, url, params={'uri': _path('non_existing.torrent')}, expected_code=500)

path = "http://localhost:1234/ubuntu.torrent"

async def mock_http_query(*_):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def get_torrent_info(self, request):
try:
tdef = TorrentDef.load(file)
metainfo = tdef.metainfo
except (TypeError, ValueError, RuntimeError):
except (FileNotFoundError, TypeError, ValueError, RuntimeError):
return RESTResponse({"error": f"error while decoding torrent file: {file}"},
status=HTTP_INTERNAL_SERVER_ERROR)
elif scheme in (HTTP_SCHEME, HTTPS_SCHEME):
Expand Down

0 comments on commit 3653f9d

Please sign in to comment.