forked from LBRYCommunity/lbry-sdk
fix not knowing a torrent exists
This commit is contained in:
parent
3f718e6efc
commit
f602541ede
3 changed files with 16 additions and 7 deletions
|
@ -805,10 +805,10 @@ class SQLiteStorage(SQLiteMixin):
|
||||||
async def save_torrent_content_claim(self, bt_infohash, claim_outpoint, length, name):
|
async def save_torrent_content_claim(self, bt_infohash, claim_outpoint, length, name):
|
||||||
def _save_torrent(transaction):
|
def _save_torrent(transaction):
|
||||||
transaction.execute(
|
transaction.execute(
|
||||||
"insert into torrent values (?, NULL, ?, ?)", (bt_infohash, length, name)
|
"insert or replace into torrent values (?, NULL, ?, ?)", (bt_infohash, length, name)
|
||||||
).fetchall()
|
).fetchall()
|
||||||
transaction.execute(
|
transaction.execute(
|
||||||
"insert into content_claim values (NULL, ?, ?)", (bt_infohash, claim_outpoint)
|
"insert or replace into content_claim values (NULL, ?, ?)", (bt_infohash, claim_outpoint)
|
||||||
).fetchall()
|
).fetchall()
|
||||||
await self.db.run(_save_torrent)
|
await self.db.run(_save_torrent)
|
||||||
# update corresponding ManagedEncryptedFileDownloader object
|
# update corresponding ManagedEncryptedFileDownloader object
|
||||||
|
|
|
@ -124,6 +124,13 @@ class FileManager:
|
||||||
raise ResolveError(f"stream for {existing[0].claim_id} collides with existing download {txo.claim_id}")
|
raise ResolveError(f"stream for {existing[0].claim_id} collides with existing download {txo.claim_id}")
|
||||||
if existing:
|
if existing:
|
||||||
log.info("claim contains a metadata only update to a stream we have")
|
log.info("claim contains a metadata only update to a stream we have")
|
||||||
|
if claim.stream.source.bt_infohash:
|
||||||
|
await self.storage.save_torrent_content_claim(
|
||||||
|
existing[0].identifier, outpoint, existing[0].torrent_length, existing[0].torrent_name
|
||||||
|
)
|
||||||
|
claim_info = await self.storage.get_content_claim_for_torrent(existing[0].identifier)
|
||||||
|
existing[0].set_claim(claim_info, claim)
|
||||||
|
else:
|
||||||
await self.storage.save_content_claim(
|
await self.storage.save_content_claim(
|
||||||
existing[0].stream_hash, outpoint
|
existing[0].stream_hash, outpoint
|
||||||
)
|
)
|
||||||
|
|
|
@ -33,7 +33,9 @@ class FileCommands(CommandTestCase):
|
||||||
|
|
||||||
async def test_download_torrent(self):
|
async def test_download_torrent(self):
|
||||||
await self.initialize_torrent()
|
await self.initialize_torrent()
|
||||||
await self.out(self.daemon.jsonrpc_get('torrent'))
|
self.assertNotIn('error', await self.out(self.daemon.jsonrpc_get('torrent')))
|
||||||
|
self.assertItemCount(await self.daemon.jsonrpc_file_list(), 1)
|
||||||
|
self.assertNotIn('error', await self.out(self.daemon.jsonrpc_get('torrent')))
|
||||||
self.assertItemCount(await self.daemon.jsonrpc_file_list(), 1)
|
self.assertItemCount(await self.daemon.jsonrpc_file_list(), 1)
|
||||||
|
|
||||||
async def create_streams_in_range(self, *args, **kwargs):
|
async def create_streams_in_range(self, *args, **kwargs):
|
||||||
|
|
Loading…
Reference in a new issue