ensuring torrent is added fully before streaming

This commit is contained in:
Anders Jensen
2018-08-25 18:03:30 +02:00
parent 015a7cbc7a
commit 21f1d77568

View File

@@ -391,8 +391,7 @@ class TorrentHandler(object):
def get_filesystem(self, infohash):
torrent = get_torrent(infohash)
status = torrent.get_status(['piece_length', 'files', 'file_progress', 'save_path'])
self.piece_length = status['piece_length']
status = torrent.get_status(['files', 'file_progress', 'save_path'])
save_path = status['save_path']
found_rar = False
@@ -456,9 +455,16 @@ class TorrentHandler(object):
@defer.inlineCallbacks
def stream(self, infohash, path, wait_for_end_pieces=False):
logger.debug('Trying to get path:%s from infohash:%s' % (path, infohash))
local_torrent = self.get_torrent(infohash)
torrent = get_torrent(infohash)
for _ in range(10):
status = torrent.get_status(['piece_length'])
if status['piece_length'] > 0:
break
yield sleep(0.2)
local_torrent = self.get_torrent(infohash)
filesystem = self.get_filesystem(infohash)
if path:
stream_item = filesystem.get_item_from_path(path)