fixed bug with internal state stale and bumped version

This commit is contained in:
Anders Jensen
2018-09-11 18:38:44 +02:00
parent d90549e60a
commit 706c0f71d3
3 changed files with 12 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ By using a small tool it is possible to it's possible to open streams directly i
## Motivation ## Motivation
The plugin is not meant to be used as a right-click to stream thing. The idea is to The plugin is not meant to be used as a right-click to stream thing. The idea is to
make Deluge an abstraction layer for the [TidalStream](http://www.tidalstream.org/) project, i.e. torrents to http on demand. make Deluge an abstraction layer for the [Tidalstream](http://www.tidalstream.org/) project, i.e. torrents to http on demand.
The _allow remote_ option is to allow remote add and stream of torrents. The _allow remote_ option is to allow remote add and stream of torrents.
@@ -51,6 +51,11 @@ The _allow remote_ option is to allow remote add and stream of torrents.
# Version Info # Version Info
## Version Unreleased
* Added label support
* Reverse proxy config / replace URL config
* Ensure internal Deluge state is updated before trying to use it
## Version 0.10.2 ## Version 0.10.2
* Busting cache when waiting for piece * Busting cache when waiting for piece
* Math error in calculating size of readable bytes * Math error in calculating size of readable bytes

View File

@@ -42,7 +42,7 @@ from setuptools import setup, find_packages
__plugin_name__ = "Streaming" __plugin_name__ = "Streaming"
__author__ = "Anders Jensen" __author__ = "Anders Jensen"
__author_email__ = "johndoee@tidalstream.org" __author_email__ = "johndoee@tidalstream.org"
__version__ = "0.10.2" __version__ = "0.10.3"
__url__ = "https://github.com/JohnDoee/deluge-streaming" __url__ = "https://github.com/JohnDoee/deluge-streaming"
__license__ = "GPLv3" __license__ = "GPLv3"
__description__ = "Enables streaming of files while downloading them." __description__ = "Enables streaming of files while downloading them."

View File

@@ -152,6 +152,7 @@ class Torrent(object):
def can_read(self, from_byte): def can_read(self, from_byte):
self.ensure_started() self.ensure_started()
status = self.torrent.get_status(['pieces'])
needed_piece, rest = divmod(from_byte, self.piece_length) needed_piece, rest = divmod(from_byte, self.piece_length)
last_available_piece = None last_available_piece = None
for piece, status in enumerate(self.torrent.status.pieces[needed_piece:], needed_piece): for piece, status in enumerate(self.torrent.status.pieces[needed_piece:], needed_piece):
@@ -178,6 +179,7 @@ class Torrent(object):
if not reactor.running: if not reactor.running:
return return
time.sleep(0.2) time.sleep(0.2)
status = self.torrent.get_status(['pieces'])
logger.debug('Calling read again to get the real number') logger.debug('Calling read again to get the real number')
return self.can_read(from_byte) return self.can_read(from_byte)
@@ -251,7 +253,7 @@ class Torrent(object):
self.torrent.set_file_priorities(file_priorities) self.torrent.set_file_priorities(file_priorities)
if self.readers: if self.readers:
status = self.torrent.get_status(['files', 'file_progress']) status = self.torrent.get_status(['files', 'file_progress', 'pieces'])
file_ranges = {} file_ranges = {}
fileset_ranges = {} fileset_ranges = {}
for path, from_byte, to_byte in self.readers.values(): for path, from_byte, to_byte in self.readers.values():
@@ -325,6 +327,7 @@ class Torrent(object):
return currently_downloading return currently_downloading
def reset_priorities(self): def reset_priorities(self):
status = self.torrent.get_status(['pieces'])
for piece in range(len(self.torrent.status.pieces)): for piece in range(len(self.torrent.status.pieces)):
self.torrent.handle.piece_priority(piece, 1) self.torrent.handle.piece_priority(piece, 1)
@@ -525,6 +528,7 @@ class TorrentHandler(object):
torrent.handle.piece_priority(piece, 7) torrent.handle.piece_priority(piece, 7)
for _ in range(220): for _ in range(220):
status = torrent.get_status(['pieces'])
for piece in wait_for_pieces: for piece in wait_for_pieces:
if not torrent.status.pieces[piece]: if not torrent.status.pieces[piece]:
break break