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():
|
if self._response_fut and not self._response_fut.done():
|
||||||
self._response_fut.cancel()
|
self._response_fut.cancel()
|
||||||
return
|
return
|
||||||
|
if self._blob_bytes_received and not self.writer.closed():
|
||||||
|
return self._write(data)
|
||||||
|
|
||||||
response = BlobResponse.deserialize(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():
|
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)
|
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
|
# 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):
|
self._write(response.blob_data)
|
||||||
data = response.blob_data[:(self.blob.get_length() - self._blob_bytes_received)]
|
|
||||||
|
|
||||||
|
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)
|
log.warning("got more than asked from %s:%d, probable sendfile bug", self.peer_address, self.peer_port)
|
||||||
else:
|
else:
|
||||||
data = response.blob_data
|
data = data
|
||||||
self._blob_bytes_received += len(data)
|
self._blob_bytes_received += len(data)
|
||||||
try:
|
try:
|
||||||
self.writer.write(data)
|
self.writer.write(data)
|
||||||
|
|
Loading…
Add table
Reference in a new issue