diff --git a/lbry/file/file_manager.py b/lbry/file/file_manager.py index 9e2ae510f..d2f7dc399 100644 --- a/lbry/file/file_manager.py +++ b/lbry/file/file_manager.py @@ -297,14 +297,17 @@ class FileManager: def get_filtered(self, *args, **kwargs) -> typing.List[ManagedDownloadSource]: """ - Get a list of filtered and sorted ManagedStream objects - - :param sort_by: field to sort by - :param reverse: reverse sorting - :param comparison: comparison operator used for filtering - :param search_by: fields and values to filter by + Get a list of filtered and sorted ManagedDownloadSource objects from all available source managers """ - return sum((manager.get_filtered(*args, **kwargs) for manager in self.source_managers.values()), []) + result = last_error = None + for manager in self.source_managers.values(): + try: + result = (result or []) + manager.get_filtered(*args, **kwargs) + except ValueError as error: + last_error = error + if result is not None: + return result + raise last_error async def delete(self, source: ManagedDownloadSource, delete_file=False): for manager in self.source_managers.values(): diff --git a/lbry/stream/stream_manager.py b/lbry/stream/stream_manager.py index 7ecf7e442..1fda2e463 100644 --- a/lbry/stream/stream_manager.py +++ b/lbry/stream/stream_manager.py @@ -32,7 +32,7 @@ def path_or_none(encoded_path) -> Optional[str]: class StreamManager(SourceManager): _sources: typing.Dict[str, ManagedStream] - filter_fields = SourceManager.filter_fields + filter_fields = set(SourceManager.filter_fields) filter_fields.update({ 'sd_hash', 'stream_hash', diff --git a/tests/integration/datanetwork/test_file_commands.py b/tests/integration/datanetwork/test_file_commands.py index c76172c95..2f7ccd21a 100644 --- a/tests/integration/datanetwork/test_file_commands.py +++ b/tests/integration/datanetwork/test_file_commands.py @@ -100,6 +100,9 @@ class FileCommands(CommandTestCase): self.assertEqual(file['total_bytes'], file['written_bytes']) self.assertEqual('finished', file['status']) + # filter by a field which is missing on torrent + self.assertItemCount(await self.daemon.jsonrpc_file_list(stream_hash="abc"), 0) + tx, new_btih = await self.initialize_torrent(tx) self.assertNotEqual(btih, new_btih) # claim now points to another torrent, update to it