catch Unknownnameerror for resolve_name
Its expected behavior that a name won't resolve so this more gracefully handles that case
This commit is contained in:
parent
9f4ccfe7c3
commit
f989814e69
2 changed files with 21 additions and 15 deletions
|
@ -10,7 +10,7 @@ at anytime.
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Fixed
|
### Fixed
|
||||||
* Add better logging to help track down [#478](https://github.com/lbryio/lbry/issues/478)
|
* Add better logging to help track down [#478](https://github.com/lbryio/lbry/issues/478)
|
||||||
|
* Catch UnknownNameErrors when resolving a name. [#479](https://github.com/lbryio/lbry/issues/479)
|
||||||
|
|
||||||
## [0.8.3rc3] - 2017-02-14
|
## [0.8.3rc3] - 2017-02-14
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ at anytime.
|
||||||
* mark peers as down if it fails download protocol
|
* mark peers as down if it fails download protocol
|
||||||
* Made hash reannounce time to be adjustable to fix [#432](https://github.com/lbryio/lbry/issues/432)
|
* Made hash reannounce time to be adjustable to fix [#432](https://github.com/lbryio/lbry/issues/432)
|
||||||
|
|
||||||
|
|
||||||
## [0.8.3rc0] - 2017-02-10
|
## [0.8.3rc0] - 2017-02-10
|
||||||
### Changed
|
### Changed
|
||||||
* Convert EncryptedFileDownloader to inlineCallbacks
|
* Convert EncryptedFileDownloader to inlineCallbacks
|
||||||
|
|
|
@ -45,7 +45,7 @@ from lbrynet.core.Wallet import LBRYumWallet, SqliteStorage
|
||||||
from lbrynet.core.looping_call_manager import LoopingCallManager
|
from lbrynet.core.looping_call_manager import LoopingCallManager
|
||||||
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
|
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
|
||||||
from lbrynet.core.server.ServerProtocol import ServerProtocolFactory
|
from lbrynet.core.server.ServerProtocol import ServerProtocolFactory
|
||||||
from lbrynet.core.Error import InsufficientFundsError
|
from lbrynet.core.Error import InsufficientFundsError, UnknownNameError
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -938,14 +938,14 @@ class Daemon(AuthJSONRPCServer):
|
||||||
fee_amount = 0.0 if fee is None else fee.amount
|
fee_amount = 0.0 if fee is None else fee.amount
|
||||||
return data_cost + fee_amount
|
return data_cost + fee_amount
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
def get_est_cost_from_name(self, name):
|
def get_est_cost_from_name(self, name):
|
||||||
"""
|
"""
|
||||||
Resolve a name and return the estimated stream cost
|
Resolve a name and return the estimated stream cost
|
||||||
"""
|
"""
|
||||||
|
metadata = yield self._resolve_name(name)
|
||||||
d = self._resolve_name(name)
|
cost = yield self._get_est_cost_from_metadata(metadata, name)
|
||||||
d.addCallback(self._get_est_cost_from_metadata, name)
|
defer.returnValue(cost)
|
||||||
return d
|
|
||||||
|
|
||||||
def get_est_cost(self, name, size=None):
|
def get_est_cost(self, name, size=None):
|
||||||
"""Get a cost estimate for a lbry stream, if size is not provided the
|
"""Get a cost estimate for a lbry stream, if size is not provided the
|
||||||
|
@ -1404,6 +1404,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
else:
|
else:
|
||||||
return self._get_lbry_file(searchtype, value)
|
return self._get_lbry_file(searchtype, value)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
def jsonrpc_resolve_name(self, name, force=False):
|
def jsonrpc_resolve_name(self, name, force=False):
|
||||||
"""
|
"""
|
||||||
Resolve stream info from a LBRY uri
|
Resolve stream info from a LBRY uri
|
||||||
|
@ -1411,15 +1412,20 @@ class Daemon(AuthJSONRPCServer):
|
||||||
Args:
|
Args:
|
||||||
'name': name to look up, string, do not include lbry:// prefix
|
'name': name to look up, string, do not include lbry:// prefix
|
||||||
Returns:
|
Returns:
|
||||||
metadata from name claim
|
metadata from name claim or None if the name is not known
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not name:
|
if not name:
|
||||||
return self._render_response(None)
|
# TODO: seems like we should raise an error here
|
||||||
|
defer.returnValue(None)
|
||||||
|
|
||||||
d = self._resolve_name(name, force_refresh=force)
|
try:
|
||||||
d.addCallback(self._render_response)
|
metadata = yield self._resolve_name(name, force_refresh=force)
|
||||||
return d
|
except UnknownNameError:
|
||||||
|
log.info('Name %s is not known', name)
|
||||||
|
defer.returnValue(None)
|
||||||
|
else:
|
||||||
|
defer.returnValue(metadata)
|
||||||
|
|
||||||
def jsonrpc_get_claim_info(self, **kwargs):
|
def jsonrpc_get_claim_info(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -1619,6 +1625,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
"""
|
"""
|
||||||
return self.jsonrpc_stream_cost_estimate(**kwargs)
|
return self.jsonrpc_stream_cost_estimate(**kwargs)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
def jsonrpc_stream_cost_estimate(self, name, size=None):
|
def jsonrpc_stream_cost_estimate(self, name, size=None):
|
||||||
"""
|
"""
|
||||||
Get estimated cost for a lbry stream
|
Get estimated cost for a lbry stream
|
||||||
|
@ -1629,10 +1636,8 @@ class Daemon(AuthJSONRPCServer):
|
||||||
Returns:
|
Returns:
|
||||||
estimated cost
|
estimated cost
|
||||||
"""
|
"""
|
||||||
|
cost = yield self.get_est_cost(name, size)
|
||||||
d = self.get_est_cost(name, size)
|
defer.returnValue(cost)
|
||||||
d.addCallback(lambda r: self._render_response(r))
|
|
||||||
return d
|
|
||||||
|
|
||||||
@AuthJSONRPCServer.auth_required
|
@AuthJSONRPCServer.auth_required
|
||||||
def jsonrpc_publish(self, name, bid, metadata, file_path=None, fee=None):
|
def jsonrpc_publish(self, name, bid, metadata, file_path=None, fee=None):
|
||||||
|
|
Loading…
Reference in a new issue