lbry-sdk/lbry
belikor 9509acc490
file_manager: raise new InvalidStreamURLError if the URL is invalid
When using `lbrynet get URL`, if the URL is not a valid URL
the function `url.URL.parse` will raise a `ValueError` exception
which will produce a whole backtrace.

For example, this is the case if we provide a channel name
with a forward slash but without a stream name.
```
lbrynet get @Non-existing/
```

```
Traceback (most recent call last):
  File "/opt/git/lbry-sdk/lbry/file/file_manager.py", line 84, in download_from_uri
    if not URL.parse(uri).has_stream:
  File "/opt/git/lbry-sdk/lbry/schema/url.py", line 114, in parse
    raise ValueError('Invalid LBRY URL')
ValueError: Invalid LBRY URL
WARNING  lbry.extras.daemon.daemon:1110: Error downloading Non-existing/: Invalid LBRY URL
```

Now we raise a new `InvalidStreamURLError` which can be trapped in the upper functions
that use `url.URL.parse` such as `FileManager.download_from_uri`.
If we do this the traceback won't be shown.
```
WARNING  lbry.file.file_manager:252:
Failed to download Non-existing/: Invalid LBRY stream URL: '@Non-existing/'
WARNING  lbry.extras.daemon.daemon:1110:
Error downloading Non-existing/: Invalid LBRY stream URL: '@Non-existing/'
```

This handles the case when trying to download only "channel" parts
without the claim part.
```
lbrynet get @Non-existing
lbrynet get @Non-existing/
lbrynet get Non-existing/
```
2021-10-15 08:59:37 -04:00
..
blob disk space metrics 2021-10-03 19:33:18 -04:00
blob_exchange non blocking blob creation 2020-04-23 00:35:08 -04:00
crypto fix decrypting invalid bytes with valid padding 2020-01-13 21:17:10 -05:00
dht dht: use bytes hex/fromhex instead of binascii 2021-09-30 13:26:33 -03:00
error file_manager: raise new InvalidStreamURLError if the URL is invalid 2021-10-15 08:59:37 -04:00
extras small fixes 2021-10-05 16:44:49 -04:00
file file_manager: raise new InvalidStreamURLError if the URL is invalid 2021-10-15 08:59:37 -04:00
schema fix setting references on txos in extra_txos 2021-10-08 16:34:15 -04:00
stream fix file reflect and add test 2021-10-04 19:26:05 -03:00
torrent tell progress, stop trying to read first piece 2020-05-07 04:04:55 -03:00
wallet clear es attributes during initial sync 2021-10-08 16:34:48 -04:00
.dockerignore residual fixes after lbrynet -> lbry move 2019-06-20 22:50:39 -04:00
__init__.py v0.105.0 2021-10-05 11:29:39 -04:00
build_info.py include docker tag in build info 2020-01-23 13:13:19 -05:00
conf.py add grin to dht known list 2021-09-30 13:26:33 -03:00
connection_manager.py pylint for lbry/connection_manager.py 2020-01-03 03:08:15 -05:00
constants.py moved lbry up one level 2020-01-01 15:57:56 -05:00
file_analysis.py upgrade pylint and fix lint errors 2021-08-20 22:36:35 -04:00
prometheus.py prometheus metrics for asyncio loop responsiveness 2021-01-01 15:25:31 -05:00
testcase.py fix abandoning signed claims in the same tx as their channel 2021-10-05 16:44:49 -04:00
utils.py upgrade pylint and fix lint errors 2021-08-20 22:36:35 -04:00
winpaths.py moved lbry up one level 2020-01-01 15:57:56 -05:00