fix tests and stream being deleted on data timeout
This commit is contained in:
parent
68d7328918
commit
cf7bb6a391
3 changed files with 14 additions and 9 deletions
|
@ -53,7 +53,7 @@ class BlobDownloader:
|
||||||
log.debug("keep peer %s:%i", peer.address, peer.tcp_port)
|
log.debug("keep peer %s:%i", peer.address, peer.tcp_port)
|
||||||
self.failures[peer] = 0
|
self.failures[peer] = 0
|
||||||
self.connections[peer] = transport
|
self.connections[peer] = transport
|
||||||
elapsed = self.loop.time - start
|
elapsed = self.loop.time() - start
|
||||||
self.scores[peer] = bytes_received / elapsed if bytes_received and elapsed else 0
|
self.scores[peer] = bytes_received / elapsed if bytes_received and elapsed else 0
|
||||||
|
|
||||||
async def new_peer_or_finished(self):
|
async def new_peer_or_finished(self):
|
||||||
|
|
|
@ -397,12 +397,17 @@ class StreamManager:
|
||||||
if not stream.descriptor:
|
if not stream.descriptor:
|
||||||
raise DownloadSDTimeout(stream.sd_hash)
|
raise DownloadSDTimeout(stream.sd_hash)
|
||||||
raise DownloadDataTimeout(stream.sd_hash)
|
raise DownloadDataTimeout(stream.sd_hash)
|
||||||
if to_replace: # delete old stream now that the replacement has started downloading
|
finally:
|
||||||
await self.delete_stream(to_replace)
|
if stream.descriptor:
|
||||||
stream.set_claim(resolved, claim)
|
if to_replace: # delete old stream now that the replacement has started downloading
|
||||||
await self.storage.save_content_claim(stream.stream_hash, outpoint)
|
await self.delete_stream(to_replace)
|
||||||
self.streams[stream.sd_hash] = stream
|
stream.set_claim(resolved, claim)
|
||||||
|
await self.storage.save_content_claim(stream.stream_hash, outpoint)
|
||||||
|
self.streams[stream.sd_hash] = stream
|
||||||
return stream
|
return stream
|
||||||
|
except DownloadDataTimeout as err: # forgive data timeout, dont delete stream
|
||||||
|
error = err
|
||||||
|
raise
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
error = err
|
error = err
|
||||||
if stream and stream.descriptor:
|
if stream and stream.descriptor:
|
||||||
|
|
|
@ -79,12 +79,12 @@ class FileCommands(CommandTestCase):
|
||||||
blob_hash for blob_hash in self.server.blob_manager.completed_blob_hashes if blob_hash != sd_hash
|
blob_hash for blob_hash in self.server.blob_manager.completed_blob_hashes if blob_hash != sd_hash
|
||||||
]
|
]
|
||||||
await self.server.blob_manager.delete_blobs(all_except_sd)
|
await self.server.blob_manager.delete_blobs(all_except_sd)
|
||||||
resp = await self.daemon.jsonrpc_get('lbry://foo', timeout=2)
|
resp = await self.daemon.jsonrpc_get('lbry://foo', timeout=2, save_file=True)
|
||||||
self.assertIn('error', resp)
|
self.assertIn('error', resp)
|
||||||
self.assertEqual('Failed to download data blobs for sd hash %s within timeout' % sd_hash, resp['error'])
|
self.assertEqual('Failed to download data blobs for sd hash %s within timeout' % sd_hash, resp['error'])
|
||||||
await self.daemon.jsonrpc_file_delete(claim_name='foo')
|
self.assertTrue(await self.daemon.jsonrpc_file_delete(claim_name='foo'), "data timeout didnt create a file")
|
||||||
await self.server.blob_manager.delete_blobs([sd_hash])
|
await self.server.blob_manager.delete_blobs([sd_hash])
|
||||||
resp = await self.daemon.jsonrpc_get('lbry://foo', timeout=2)
|
resp = await self.daemon.jsonrpc_get('lbry://foo', timeout=2, save_file=True)
|
||||||
self.assertIn('error', resp)
|
self.assertIn('error', resp)
|
||||||
self.assertEqual('Failed to download sd blob %s within timeout' % sd_hash, resp['error'])
|
self.assertEqual('Failed to download sd blob %s within timeout' % sd_hash, resp['error'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue