status code for previously downloaded file

also fix return for files downloaded manually with stream_info
This commit is contained in:
Jack 2016-05-05 21:45:25 -04:00
parent 29d6d824fc
commit b017b63745

View file

@ -1078,6 +1078,11 @@ class LBRYDaemon(jsonrpc.JSONRPC):
if search_by == "name": if search_by == "name":
if val in self.streams.keys(): if val in self.streams.keys():
status = self.streams[val].code status = self.streams[val].code
elif f in self.lbry_file_manager.lbry_files:
# if f.stopped:
# status = STREAM_STAGES[3]
# else:
status = STREAM_STAGES[2]
else: else:
status = [False, False] status = [False, False]
else: else:
@ -1449,6 +1454,10 @@ class LBRYDaemon(jsonrpc.JSONRPC):
if 'stream_info' in p.keys(): if 'stream_info' in p.keys():
stream_info = p['stream_info'] stream_info = p['stream_info']
if 'sources' in stream_info.keys():
sd_hash = stream_info['sources']['lbry_sd_hash']
else:
sd_hash = stream_info['stream_hash']
else: else:
stream_info = None stream_info = None
@ -1457,7 +1466,11 @@ class LBRYDaemon(jsonrpc.JSONRPC):
if p['name'] not in self.waiting_on.keys(): if p['name'] not in self.waiting_on.keys():
d = self._download_name(name=name, timeout=timeout, download_directory=download_directory, d = self._download_name(name=name, timeout=timeout, download_directory=download_directory,
stream_info=stream_info, file_name=file_name) stream_info=stream_info, file_name=file_name)
d.addCallback(lambda l: {'stream_hash': l.sd_hash, 'path': os.path.join(self.download_directory, l.file_name)}) d.addCallback(lambda l: {'stream_hash': sd_hash,
'path': os.path.join(self.download_directory, l.file_name)}
if stream_info else
{'stream_hash': l.sd_hash,
'path': os.path.join(self.download_directory, l.file_name)})
d.addCallback(lambda message: self._render_response(message, OK_CODE)) d.addCallback(lambda message: self._render_response(message, OK_CODE))
else: else:
d = server.failure d = server.failure