use FileBodyProducer for encrypt_blob script

This commit is contained in:
Victor Shyba 2017-07-18 04:31:35 -03:00 committed by Jack Robison
parent 7262e84150
commit a3e5c61b50
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF

View file

@ -5,6 +5,8 @@ import sys
from twisted.internet import defer from twisted.internet import defer
from twisted.internet import reactor from twisted.internet import reactor
from twisted.protocols import basic
from twisted.web.client import FileBodyProducer
from lbrynet import conf from lbrynet import conf
from lbrynet.core import log_support from lbrynet.core import log_support
@ -46,10 +48,8 @@ def encrypt_blob(filename, key, iv):
yield manager.setup() yield manager.setup()
creator = CryptStreamCreator(manager, filename, key, iv_generator(iv)) creator = CryptStreamCreator(manager, filename, key, iv_generator(iv))
with open(filename, 'r') as infile: with open(filename, 'r') as infile:
data = infile.read(2**14) producer = FileBodyProducer(infile, readSize=2**22)
while data: yield producer.startProducing(creator)
yield creator.write(data)
data = infile.read(2**14)
yield creator.stop() yield creator.stop()