diff --git a/lbry/file/file_manager.py b/lbry/file/file_manager.py index 094ab1edc..eafba2f11 100644 --- a/lbry/file/file_manager.py +++ b/lbry/file/file_manager.py @@ -117,9 +117,11 @@ class FileManager: if claim.stream.source.bt_infohash: source_manager = self.source_managers['torrent'] existing = source_manager.get_filtered(bt_infohash=claim.stream.source.bt_infohash) - else: + elif claim.stream.source.sd_hash: source_manager = self.source_managers['stream'] existing = source_manager.get_filtered(sd_hash=claim.stream.source.sd_hash) + else: + raise ResolveError(f"There is nothing to download at {uri} - Source is unknown or unset") # resume or update an existing stream, if the stream changed: download it and delete the old one after to_replace, updated_stream = None, None diff --git a/lbry/testcase.py b/lbry/testcase.py index 3fb5e2ddf..68c07f2df 100644 --- a/lbry/testcase.py +++ b/lbry/testcase.py @@ -480,7 +480,7 @@ class CommandTestCase(IntegrationTestCase): async def stream_create( self, name='hovercraft', bid='1.0', file_path=None, data=b'hi!', confirm=True, prefix=None, suffix=None, **kwargs): - if file_path is None: + if file_path is None and data is not None: file_path = self.create_upload_file(data=data, prefix=prefix, suffix=suffix) return await self.confirm_and_render( self.daemon.jsonrpc_stream_create(name, bid, file_path=file_path, **kwargs), confirm diff --git a/tests/integration/datanetwork/test_file_commands.py b/tests/integration/datanetwork/test_file_commands.py index 306cacf12..0bf9160bc 100644 --- a/tests/integration/datanetwork/test_file_commands.py +++ b/tests/integration/datanetwork/test_file_commands.py @@ -221,6 +221,20 @@ class FileCommands(CommandTestCase): file_list = (await self.daemon.jsonrpc_file_list())['items'] self.assertEqual(file_list[0].stream_claim_info.claim.stream.description, claim.stream.description) + async def test_sourceless_content(self): + # claim has no source, then it has one + tx = await self.stream_create('foo', '0.01', data=None) + claim_id = self.get_claim_id(tx) + await self.daemon.jsonrpc_file_delete(claim_name='foo') + response = await self.out(self.daemon.jsonrpc_get('lbry://foo')) + self.assertIn('error', response) + self.assertIn('nothing to download', response['error']) + # source is set (there isn't a way to clear the source field, so we stop here for now) + await self.stream_update(claim_id, data=b'surpriiiiiiiise') + response = await self.out(self.daemon.jsonrpc_get('lbry://foo')) + self.assertNotIn('error', response) + self.assertItemCount(await self.daemon.jsonrpc_file_list(), 1) + async def test_file_list_paginated_output(self): await self.create_streams_in_range(0, 20)