forked from LBRYCommunity/lbry-sdk
bypass parser during download
This commit is contained in:
parent
a616582733
commit
5586a226c2
1 changed files with 23 additions and 17 deletions
|
@ -32,6 +32,8 @@ class BlobExchangeClientProtocol(asyncio.Protocol):
|
|||
if self._response_fut and not self._response_fut.done():
|
||||
self._response_fut.cancel()
|
||||
return
|
||||
if self._blob_bytes_received and not self.writer.closed():
|
||||
return self._write(data)
|
||||
|
||||
response = BlobResponse.deserialize(data)
|
||||
|
||||
|
@ -51,11 +53,15 @@ class BlobExchangeClientProtocol(asyncio.Protocol):
|
|||
if response.blob_data and self.writer and not self.writer.closed():
|
||||
log.debug("got %i blob bytes from %s:%i", len(response.blob_data), self.peer_address, self.peer_port)
|
||||
# write blob bytes if we're writing a blob and have blob bytes to write
|
||||
if len(response.blob_data) > (self.blob.get_length() - self._blob_bytes_received):
|
||||
data = response.blob_data[:(self.blob.get_length() - self._blob_bytes_received)]
|
||||
self._write(response.blob_data)
|
||||
|
||||
|
||||
def _write(self, data):
|
||||
if len(data) > (self.blob.get_length() - self._blob_bytes_received):
|
||||
data = data[:(self.blob.get_length() - self._blob_bytes_received)]
|
||||
log.warning("got more than asked from %s:%d, probable sendfile bug", self.peer_address, self.peer_port)
|
||||
else:
|
||||
data = response.blob_data
|
||||
data = data
|
||||
self._blob_bytes_received += len(data)
|
||||
try:
|
||||
self.writer.write(data)
|
||||
|
|
Loading…
Reference in a new issue