fix filtering for fields missing on torrents
This commit is contained in:
parent
39da718c28
commit
8ce53069ad
3 changed files with 14 additions and 8 deletions
|
@ -297,14 +297,17 @@ class FileManager:
|
||||||
|
|
||||||
def get_filtered(self, *args, **kwargs) -> typing.List[ManagedDownloadSource]:
|
def get_filtered(self, *args, **kwargs) -> typing.List[ManagedDownloadSource]:
|
||||||
"""
|
"""
|
||||||
Get a list of filtered and sorted ManagedStream objects
|
Get a list of filtered and sorted ManagedDownloadSource objects from all available source managers
|
||||||
|
|
||||||
: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
|
|
||||||
"""
|
"""
|
||||||
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):
|
async def delete(self, source: ManagedDownloadSource, delete_file=False):
|
||||||
for manager in self.source_managers.values():
|
for manager in self.source_managers.values():
|
||||||
|
|
|
@ -32,7 +32,7 @@ def path_or_none(encoded_path) -> Optional[str]:
|
||||||
class StreamManager(SourceManager):
|
class StreamManager(SourceManager):
|
||||||
_sources: typing.Dict[str, ManagedStream]
|
_sources: typing.Dict[str, ManagedStream]
|
||||||
|
|
||||||
filter_fields = SourceManager.filter_fields
|
filter_fields = set(SourceManager.filter_fields)
|
||||||
filter_fields.update({
|
filter_fields.update({
|
||||||
'sd_hash',
|
'sd_hash',
|
||||||
'stream_hash',
|
'stream_hash',
|
||||||
|
|
|
@ -100,6 +100,9 @@ class FileCommands(CommandTestCase):
|
||||||
self.assertEqual(file['total_bytes'], file['written_bytes'])
|
self.assertEqual(file['total_bytes'], file['written_bytes'])
|
||||||
self.assertEqual('finished', file['status'])
|
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)
|
tx, new_btih = await self.initialize_torrent(tx)
|
||||||
self.assertNotEqual(btih, new_btih)
|
self.assertNotEqual(btih, new_btih)
|
||||||
# claim now points to another torrent, update to it
|
# claim now points to another torrent, update to it
|
||||||
|
|
Loading…
Add table
Reference in a new issue