Pass SQLite storage object to DiskBlobManager for single(temp) blob download

This commit is contained in:
hackrush 2018-10-11 00:28:46 +05:30 committed by Jack Robison
parent 3364ac0976
commit a692b6ff7d
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -11,6 +11,7 @@ from lbrynet.core.PaymentRateManager import OnlyFreePaymentsManager
from lbrynet.core.client.BlobRequester import BlobRequester from lbrynet.core.client.BlobRequester import BlobRequester
from lbrynet.core.client.StandaloneBlobDownloader import StandaloneBlobDownloader from lbrynet.core.client.StandaloneBlobDownloader import StandaloneBlobDownloader
from lbrynet.core.client.ConnectionManager import ConnectionManager from lbrynet.core.client.ConnectionManager import ConnectionManager
from lbrynet.database.storage import SQLiteStorage
from lbrynet.dht.peerfinder import DummyPeerFinder from lbrynet.dht.peerfinder import DummyPeerFinder
@ -96,10 +97,13 @@ class SinglePeerDownloader:
@defer.inlineCallbacks @defer.inlineCallbacks
def download_temp_blob_from_peer(self, peer, timeout, blob_hash): def download_temp_blob_from_peer(self, peer, timeout, blob_hash):
tmp_dir = yield threads.deferToThread(tempfile.mkdtemp) tmp_dir = yield threads.deferToThread(tempfile.mkdtemp)
tmp_blob_manager = DiskBlobManager(tmp_dir, tmp_dir) tmp_storage = SQLiteStorage(tmp_dir)
yield tmp_storage.setup()
tmp_blob_manager = DiskBlobManager(tmp_dir, tmp_storage)
try: try:
result = yield self.download_blob_from_peer(peer, timeout, blob_hash, tmp_blob_manager) result = yield self.download_blob_from_peer(peer, timeout, blob_hash, tmp_blob_manager)
finally: finally:
yield tmp_blob_manager.stop() yield tmp_blob_manager.stop()
yield tmp_storage.stop()
yield threads.deferToThread(shutil.rmtree, tmp_dir) yield threads.deferToThread(shutil.rmtree, tmp_dir)
defer.returnValue(result) defer.returnValue(result)