add get_sd_hash to utils

This commit is contained in:
Jack Robison 2017-03-09 10:39:17 -05:00
parent 9a4230dd96
commit 5d6ca0aae6
2 changed files with 7 additions and 7 deletions

View file

@ -108,3 +108,9 @@ def random_string(length=10, chars=string.ascii_lowercase):
def short_hash(hash_str): def short_hash(hash_str):
return hash_str[:6] return hash_str[:6]
def get_sd_hash(stream_info):
if not stream_info:
return None
return stream_info['sources']['lbry_sd_hash']

View file

@ -2342,12 +2342,6 @@ class Daemon(AuthJSONRPCServer):
return d return d
def get_sd_hash(stream_info):
if not stream_info:
return None
return stream_info['sources']['lbry_sd_hash']
class _DownloadNameHelper(object): class _DownloadNameHelper(object):
def __init__(self, daemon, name, timeout=None, download_directory=None, file_name=None, def __init__(self, daemon, name, timeout=None, download_directory=None, file_name=None,
wait_for_write=True): wait_for_write=True):
@ -2363,7 +2357,7 @@ class _DownloadNameHelper(object):
@defer.inlineCallbacks @defer.inlineCallbacks
def setup_stream(self, stream_info): def setup_stream(self, stream_info):
sd_hash = get_sd_hash(stream_info) sd_hash = utils.get_sd_hash(stream_info)
lbry_file = yield self.daemon._get_lbry_file(FileID.SD_HASH, sd_hash, return_json=False) lbry_file = yield self.daemon._get_lbry_file(FileID.SD_HASH, sd_hash, return_json=False)
if self._does_lbry_file_exists(lbry_file): if self._does_lbry_file_exists(lbry_file):
defer.returnValue(lbry_file) defer.returnValue(lbry_file)