From a116dcd3bb73a48b3dff0fd63c9e7b9d11d452b1 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 15 Nov 2019 15:25:19 -0500 Subject: [PATCH] add SQLiteStorage.delete_torrent --- lbry/lbry/extras/daemon/storage.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lbry/lbry/extras/daemon/storage.py b/lbry/lbry/extras/daemon/storage.py index de1600aa8..b5859d6c1 100644 --- a/lbry/lbry/extras/daemon/storage.py +++ b/lbry/lbry/extras/daemon/storage.py @@ -204,6 +204,15 @@ def delete_stream(transaction: sqlite3.Connection, descriptor: 'StreamDescriptor transaction.executemany("delete from blob where blob_hash=?", blob_hashes).fetchall() +def delete_torrent(transaction: sqlite3.Connection, bt_infohash: str): + transaction.execute("delete from content_claim where bt_infohash=?", (bt_infohash, )).fetchall() + transaction.execute("delete from torrent_tracker where bt_infohash=?", (bt_infohash,)).fetchall() + transaction.execute("delete from torrent_node where bt_infohash=?", (bt_infohash,)).fetchall() + transaction.execute("delete from torrent_http_seed where bt_infohash=?", (bt_infohash,)).fetchall() + transaction.execute("delete from file where bt_infohash=?", (bt_infohash,)).fetchall() + transaction.execute("delete from torrent where bt_infohash=?", (bt_infohash,)).fetchall() + + def store_file(transaction: sqlite3.Connection, stream_hash: str, file_name: typing.Optional[str], download_directory: typing.Optional[str], data_payment_rate: float, status: str, content_fee: typing.Optional[Transaction], added_on: typing.Optional[int] = None) -> int: @@ -496,6 +505,9 @@ class SQLiteStorage(SQLiteMixin): def delete_stream(self, descriptor: 'StreamDescriptor'): return self.db.run_with_foreign_keys_disabled(delete_stream, descriptor) + async def delete_torrent(self, bt_infohash: str): + return await self.db.run(delete_torrent, bt_infohash) + # # # # # # # # # file stuff # # # # # # # # # def save_downloaded_file(self, stream_hash: str, file_name: typing.Optional[str],