|
5 | 5 | import asyncio |
6 | 6 | import binascii |
7 | 7 | import time |
| 8 | +from operator import itemgetter |
8 | 9 | from typing import Optional |
9 | 10 | from lbry.wallet import SQLiteMixin |
10 | 11 | from lbry.conf import Config |
@@ -635,6 +636,15 @@ def update_db_removed(transaction: sqlite3.Connection, removed): |
635 | 636 | def get_all_lbry_files(self) -> typing.Awaitable[typing.List[typing.Dict]]: |
636 | 637 | return self.db.run(get_all_lbry_files) |
637 | 638 |
|
| 639 | + async def get_all_torrent_files(self) -> typing.List[typing.Dict]: |
| 640 | + def _get_all_torrent_files(transaction): |
| 641 | + cursor = transaction.execute("select * from file join torrent on file.bt_infohash=torrent.bt_infohash") |
| 642 | + return [ |
| 643 | + {field: value for field, value in zip(list(map(itemgetter(0), cursor.description)), row)} |
| 644 | + for row in cursor.fetchall() |
| 645 | + ] |
| 646 | + return await self.db.run(_get_all_torrent_files) |
| 647 | + |
638 | 648 | def change_file_status(self, stream_hash: str, new_status: str): |
639 | 649 | log.debug("update file status %s -> %s", stream_hash, new_status) |
640 | 650 | return self.db.execute_fetchall("update file set status=? where stream_hash=?", (new_status, stream_hash)) |
@@ -907,7 +917,7 @@ async def get_content_claim(self, stream_hash: str, include_supports: typing.Opt |
907 | 917 |
|
908 | 918 | async def get_content_claim_for_torrent(self, bt_infohash): |
909 | 919 | claims = await self.db.run(get_claims_from_torrent_info_hashes, [bt_infohash]) |
910 | | - return claims[bt_infohash].as_dict() if claims else None |
| 920 | + return claims[bt_infohash] if claims else None |
911 | 921 |
|
912 | 922 | # # # # # # # # # reflector functions # # # # # # # # # |
913 | 923 |
|
|
0 commit comments