forked from LBRYCommunity/lbry-sdk
tell progress, stop trying to read first piece
This commit is contained in:
parent
53382b7e15
commit
f145d08c10
3 changed files with 8 additions and 7 deletions
|
@ -291,9 +291,9 @@ class JSONResponseEncoder(JSONEncoder):
|
|||
'sd_hash': managed_stream.descriptor.sd_hash if is_stream else None,
|
||||
'mime_type': managed_stream.mime_type if is_stream else None,
|
||||
'key': managed_stream.descriptor.key if is_stream else None,
|
||||
'total_bytes_lower_bound': managed_stream.descriptor.lower_bound_decrypted_length() if is_stream else None,
|
||||
'total_bytes': managed_stream.descriptor.upper_bound_decrypted_length() if is_stream else None,
|
||||
'written_bytes': managed_stream.written_bytes if is_stream else None,
|
||||
'total_bytes_lower_bound': managed_stream.descriptor.lower_bound_decrypted_length() if is_stream else managed_stream.torrent_length,
|
||||
'total_bytes': managed_stream.descriptor.upper_bound_decrypted_length() if is_stream else managed_stream.torrent_length,
|
||||
'written_bytes': managed_stream.written_bytes if is_stream else managed_stream.written_bytes,
|
||||
'blobs_completed': managed_stream.blobs_completed if is_stream else None,
|
||||
'blobs_in_stream': managed_stream.blobs_in_stream if is_stream else None,
|
||||
'blobs_remaining': managed_stream.blobs_remaining if is_stream else None,
|
||||
|
|
|
@ -40,8 +40,6 @@ log = logging.getLogger(__name__)
|
|||
|
||||
DEFAULT_FLAGS = ( # fixme: somehow the logic here is inverted?
|
||||
libtorrent.add_torrent_params_flags_t.flag_auto_managed
|
||||
| libtorrent.add_torrent_params_flags_t.flag_paused
|
||||
| libtorrent.add_torrent_params_flags_t.flag_duplicate_is_error
|
||||
| libtorrent.add_torrent_params_flags_t.flag_update_subscribe
|
||||
)
|
||||
|
||||
|
@ -104,7 +102,6 @@ class TorrentHandle:
|
|||
self.torrent_file = self._handle.get_torrent_info().files()
|
||||
self._base_path = status.save_path
|
||||
first_piece = self.torrent_file.at(self.largest_file_index).offset
|
||||
self._handle.read_piece(first_piece)
|
||||
if not self.started.is_set():
|
||||
if self._handle.have_piece(first_piece):
|
||||
self.started.set()
|
||||
|
@ -205,7 +202,7 @@ class TorrentSession:
|
|||
)
|
||||
|
||||
def _add_torrent(self, btih: str, download_directory: Optional[str]):
|
||||
params = {'info_hash': binascii.unhexlify(btih.encode())}
|
||||
params = {'info_hash': binascii.unhexlify(btih.encode()), 'flags': DEFAULT_FLAGS}
|
||||
if download_directory:
|
||||
params['save_path'] = download_directory
|
||||
handle = self._session.add_torrent(params)
|
||||
|
|
|
@ -62,6 +62,10 @@ class TorrentSource(ManagedDownloadSource):
|
|||
def torrent_length(self):
|
||||
return self.torrent_session.get_size(self.identifier)
|
||||
|
||||
@property
|
||||
def written_bytes(self):
|
||||
return self.torrent_session.get_downloaded(self.identifier)
|
||||
|
||||
@property
|
||||
def torrent_name(self):
|
||||
return self.torrent_session.get_name(self.identifier)
|
||||
|
|
Loading…
Reference in a new issue