From 32902463b82d6cc1f48020e033eae6cdf0761178 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 1 Nov 2022 17:59:49 -0300 Subject: [PATCH] restore torrent rowid on restart --- lbry/extras/daemon/storage.py | 3 ++- lbry/torrent/torrent_manager.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lbry/extras/daemon/storage.py b/lbry/extras/daemon/storage.py index a36f7e9698..65e7cfcd19 100644 --- a/lbry/extras/daemon/storage.py +++ b/lbry/extras/daemon/storage.py @@ -638,7 +638,8 @@ def get_all_lbry_files(self) -> typing.Awaitable[typing.List[typing.Dict]]: async def get_all_torrent_files(self) -> typing.List[typing.Dict]: def _get_all_torrent_files(transaction): - cursor = transaction.execute("select * from file join torrent on file.bt_infohash=torrent.bt_infohash") + cursor = transaction.execute( + "select file.ROWID as rowid, * from file join torrent on file.bt_infohash=torrent.bt_infohash") return map(lambda row: dict(zip(list(map(itemgetter(0), cursor.description)), row)), cursor.fetchall()) return list(await self.db.run(_get_all_torrent_files)) diff --git a/lbry/torrent/torrent_manager.py b/lbry/torrent/torrent_manager.py index ce873b07cf..a6e9c89419 100644 --- a/lbry/torrent/torrent_manager.py +++ b/lbry/torrent/torrent_manager.py @@ -183,7 +183,7 @@ async def initialize_from_database(self): claim = await self.storage.get_content_claim_for_torrent(file['bt_infohash']) file['download_directory'] = bytes.fromhex(file['download_directory'] or '').decode() or None file['file_name'] = bytes.fromhex(file['file_name'] or '').decode() or None - await self._load_stream(None, claim=claim, **file) + await self._load_stream(claim=claim, **file) async def start(self): await super().start()