added buffer buster and some wrong math

This commit is contained in:
Anders Jensen
2018-08-25 17:53:55 +02:00
parent 3417b109ec
commit 015a7cbc7a
2 changed files with 4 additions and 1 deletions

View File

@@ -182,7 +182,7 @@ class Torrent(object):
logger.debug('Calling read again to get the real number')
return self.can_read(from_byte)
else:
return ((last_available_piece - needed_piece) * self.piece_length) + rest + self.piece_length
return ((last_available_piece - needed_piece) * self.piece_length) + self.piece_length - rest
def is_idle(self):
return not self.readers and self.last_activity + TORRENT_CLEANUP_INTERVAL < datetime.now()

View File

@@ -50,6 +50,9 @@ class DelugeTorrentInput(InputBase.find_plugin('file')):
if self.can_read_to <= tell or self.can_read_to is None:
self.can_read_to = self.torrent.can_read(self.offset + tell) + tell
if self._open_file:
self._open_file.seek(tell)
real_num = min(num, self.can_read_to - tell)
if num != real_num:
logger.info('The real number we can read to is %s and not %s at position %s' % (real_num, num, tell))