Merge branch 'atiaxi-blob-list-uri-fix'

This commit is contained in:
Jack Robison 2018-02-06 22:55:02 -05:00
commit 1c45cf05d7
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
4 changed files with 43 additions and 2 deletions

View file

@ -22,6 +22,7 @@ at anytime.
* Fixed handling decryption error for blobs encrypted with an invalid key
* Fixed handling stream with no data blob (https://github.com/lbryio/lbry/issues/905)
* Fixed fetching the external ip
* Fixed API call to blob_list with --uri parameter (https://github.com/lbryio/lbry/issues/895)
### Deprecated
* `channel_list_mine`, replaced with `channel_list`

View file

@ -134,7 +134,14 @@ def get_sd_hash(stream_info):
return None
if isinstance(stream_info, ClaimDict):
return stream_info.source_hash
return stream_info['stream']['source']['source']
result = stream_info.get('claim', {}).\
get('value', {}).\
get('stream', {}).\
get('source', {}).\
get('source')
if not result:
log.warn("Unable to get sd_hash")
return result
def json_dumps_pretty(obj, **kwargs):

View file

@ -2881,7 +2881,10 @@ class Daemon(AuthJSONRPCServer):
if uri:
metadata = yield self._resolve_name(uri)
sd_hash = utils.get_sd_hash(metadata)
try:
blobs = yield self.get_blobs_for_sd_hash(sd_hash)
except NoSuchSDHash:
blobs = []
elif stream_hash:
try:
blobs = yield self.get_blobs_for_stream_hash(stream_hash)

View file

@ -31,3 +31,33 @@ class ObfuscationTest(unittest.TestCase):
plain = ''
obf = utils.obfuscate(plain)
self.assertEqual(plain, utils.deobfuscate(obf))
class SdHashTests(unittest.TestCase):
def test_none_in_none_out(self):
self.assertIsNone(utils.get_sd_hash(None))
def test_ordinary_dict(self):
claim = {
"claim": {
"value": {
"stream": {
"source": {
"source": "0123456789ABCDEF"
}
}
}
}
}
self.assertEqual("0123456789ABCDEF", utils.get_sd_hash(claim))
def test_old_shape_fails(self):
claim = {
"stream": {
"source": {
"source": "0123456789ABCDEF"
}
}
}
self.assertIsNone(utils.get_sd_hash(claim))