lbry-sdk/lbry
belikor 65323b4169 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/
```
2022-03-15 15:34:08 -03:00
..
blob disk space metrics 2022-03-15 15:34:07 -03: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 2022-03-15 15:34:07 -03:00
error file_manager: raise new InvalidStreamURLError if the URL is invalid 2022-03-15 15:34:08 -03:00
extras small fixes 2022-03-15 15:34:07 -03:00
file file_manager: raise new InvalidStreamURLError if the URL is invalid 2022-03-15 15:34:08 -03:00
schema fix setting references on txos in extra_txos 2022-03-15 15:34:08 -03:00
stream fix file reflect and add test 2022-03-15 15:34:07 -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 2022-03-15 15:34:08 -03:00
.dockerignore residual fixes after lbrynet -> lbry move 2019-06-20 22:50:39 -04:00
__init__.py v0.105.0 2022-03-15 15:34:07 -03: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 2022-03-15 15:34:07 -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 2022-03-15 15:34:07 -03: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