return file json from get
This commit is contained in:
parent
7ad46e70be
commit
bc9b990728
2 changed files with 54 additions and 48 deletions
|
@ -18,7 +18,8 @@ at anytime.
|
||||||
* Refactor file_list, add `full_status` argument to populate resource intensive fields
|
* Refactor file_list, add `full_status` argument to populate resource intensive fields
|
||||||
* Remove deprecated file commands: `get_lbry_files`, `get_lbry_file`, and `file_get`
|
* Remove deprecated file commands: `get_lbry_files`, `get_lbry_file`, and `file_get`
|
||||||
* Remove deprecated `delete_lbry_file` command
|
* Remove deprecated `delete_lbry_file` command
|
||||||
|
* Return standard file json from `get`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -28,6 +29,10 @@ at anytime.
|
||||||
### Fixed
|
### Fixed
|
||||||
* Fixed ExchangeRateManager freezing the app
|
* Fixed ExchangeRateManager freezing the app
|
||||||
* Fixed download not timing out properly when downloading sd blob
|
* Fixed download not timing out properly when downloading sd blob
|
||||||
|
* Fixed ExchangeRateManager freezing the app
|
||||||
|
* Fixed download not timing out properly when downloading sd blob
|
||||||
|
* Fixed get not reassembling an already downloaded file that was deleted from download directory
|
||||||
|
*
|
||||||
|
|
||||||
## [0.9.0rc11] - 2017-02-27
|
## [0.9.0rc11] - 2017-02-27
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -1553,64 +1553,65 @@ class Daemon(AuthJSONRPCServer):
|
||||||
'wait_for_write': optional, defaults to True. When set, waits for the file to
|
'wait_for_write': optional, defaults to True. When set, waits for the file to
|
||||||
only start to be written before returning any results.
|
only start to be written before returning any results.
|
||||||
Returns:
|
Returns:
|
||||||
'stream_hash': hex string
|
{
|
||||||
'path': path of download
|
'completed': bool,
|
||||||
|
'file_name': str,
|
||||||
|
'download_directory': str,
|
||||||
|
'points_paid': float,
|
||||||
|
'stopped': bool,
|
||||||
|
'stream_hash': str (hex),
|
||||||
|
'stream_name': str,
|
||||||
|
'suggested_file_name': str,
|
||||||
|
'sd_hash': str (hex),
|
||||||
|
'name': str,
|
||||||
|
'outpoint': str, (txid:nout)
|
||||||
|
'claim_id': str (hex),
|
||||||
|
'download_path': str,
|
||||||
|
'mime_type': str,
|
||||||
|
'key': str (hex),
|
||||||
|
'total_bytes': int
|
||||||
|
'written_bytes': int,
|
||||||
|
'message': str
|
||||||
|
'metadata': Metadata dict
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
timeout = timeout if timeout is not None else self.download_timeout
|
timeout = timeout if timeout is not None else self.download_timeout
|
||||||
download_directory = download_directory or self.download_directory
|
download_directory = download_directory or self.download_directory
|
||||||
sd_hash = get_sd_hash(stream_info)
|
|
||||||
if name in self.waiting_on:
|
if name in self.waiting_on:
|
||||||
# TODO: return a useful error message here, like "already
|
log.info("Already waiting on lbry://%s to start downloading", name)
|
||||||
# waiting for name to be resolved"
|
yield self.streams[name].data_downloading_deferred
|
||||||
defer.returnValue(server.failure)
|
|
||||||
|
|
||||||
# first check if we already have this
|
|
||||||
lbry_file = yield self._get_lbry_file(FileID.NAME, name, return_json=False)
|
lbry_file = yield self._get_lbry_file(FileID.NAME, name, return_json=False)
|
||||||
if lbry_file:
|
|
||||||
log.info('Already have a file for %s', name)
|
|
||||||
message = {
|
|
||||||
'stream_hash': sd_hash if stream_info else lbry_file.sd_hash,
|
|
||||||
'path': os.path.join(lbry_file.download_directory, lbry_file.file_name)
|
|
||||||
}
|
|
||||||
response = yield self._render_response(message)
|
|
||||||
defer.returnValue(response)
|
|
||||||
|
|
||||||
download_id = utils.random_string()
|
if lbry_file:
|
||||||
self.analytics_manager.send_download_started(download_id, name, stream_info)
|
if not os.path.isfile(os.path.join(lbry_file.download_directory, lbry_file.file_name)):
|
||||||
tries = 1
|
log.info("Already have lbry file but missing file in %s, rebuilding it",
|
||||||
max_tries = 3
|
lbry_file.download_directory)
|
||||||
while tries <= max_tries:
|
yield lbry_file.start()
|
||||||
|
else:
|
||||||
|
log.info('Already have a file for %s', name)
|
||||||
|
result = yield self._get_lbry_file_dict(lbry_file, full_status=True)
|
||||||
|
else:
|
||||||
|
download_id = utils.random_string()
|
||||||
|
self.analytics_manager.send_download_started(download_id, name, stream_info)
|
||||||
try:
|
try:
|
||||||
log.info('Making try %s / %s to start download of %s', tries, max_tries, name)
|
yield self._download_name(name=name, timeout=timeout,
|
||||||
new_sd_hash, file_path = yield self._download_name(
|
download_directory=download_directory,
|
||||||
name=name,
|
stream_info=stream_info, file_name=file_name,
|
||||||
timeout=timeout,
|
wait_for_write=wait_for_write)
|
||||||
download_directory=download_directory,
|
stream = self.streams[name]
|
||||||
stream_info=stream_info,
|
stream.finished_deferred.addCallback(
|
||||||
file_name=file_name,
|
lambda _: self.analytics_manager.send_download_finished(
|
||||||
wait_for_write=wait_for_write
|
download_id, name, stream_info)
|
||||||
)
|
)
|
||||||
break
|
result = yield self._get_lbry_file_dict(self.streams[name].downloader,
|
||||||
|
full_status=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.warning('Failed to get %s', name)
|
log.warning('Failed to get %s', name)
|
||||||
if tries == max_tries:
|
self.analytics_manager.send_download_errored(download_id, name, stream_info)
|
||||||
self.analytics_manager.send_download_errored(download_id, name, stream_info)
|
result = e.message
|
||||||
response = yield self._render_response(e.message)
|
response = yield self._render_response(result)
|
||||||
defer.returnValue(response)
|
|
||||||
tries += 1
|
|
||||||
# TODO: should stream_hash key be changed to sd_hash?
|
|
||||||
message = {
|
|
||||||
'stream_hash': sd_hash if stream_info else new_sd_hash,
|
|
||||||
'path': file_path
|
|
||||||
}
|
|
||||||
stream = self.streams.get(name)
|
|
||||||
if stream:
|
|
||||||
stream.finished_deferred.addCallback(
|
|
||||||
lambda _: self.analytics_manager.send_download_finished(
|
|
||||||
download_id, name, stream_info)
|
|
||||||
)
|
|
||||||
response = yield self._render_response(message)
|
|
||||||
defer.returnValue(response)
|
defer.returnValue(response)
|
||||||
|
|
||||||
@AuthJSONRPCServer.auth_required
|
@AuthJSONRPCServer.auth_required
|
||||||
|
@ -1635,7 +1636,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
'status': "start" or "stop"
|
'status': "start" or "stop"
|
||||||
'name': start file by lbry uri,
|
'name': start file by lbry name,
|
||||||
'sd_hash': start file by the hash in the name claim,
|
'sd_hash': start file by the hash in the name claim,
|
||||||
'file_name': start file by its name in the downloads folder,
|
'file_name': start file by its name in the downloads folder,
|
||||||
Returns:
|
Returns:
|
||||||
|
|
Loading…
Reference in a new issue