Just do whole thing in one thread job

This commit is contained in:
Itamar Turner-Trauring 2023-10-19 11:09:54 -04:00
parent 7f53f40d76
commit 5d896e8035

View File

@ -729,18 +729,17 @@ class Publish(object):
assert len(data) == segsize, len(data) assert len(data) == segsize, len(data)
salt = os.urandom(16)
key = await defer_to_thread(hashutil.ssk_readkey_data_hash, salt, self.readkey)
self._status.set_status("Encrypting") self._status.set_status("Encrypting")
def encrypt(): def encrypt(readkey):
salt = os.urandom(16)
key = hashutil.ssk_readkey_data_hash(salt, readkey)
encryptor = aes.create_encryptor(key) encryptor = aes.create_encryptor(key)
crypttext = aes.encrypt_data(encryptor, data) crypttext = aes.encrypt_data(encryptor, data)
assert len(crypttext) == len(data) assert len(crypttext) == len(data)
return crypttext return salt, crypttext
crypttext = await defer_to_thread(encrypt) salt, crypttext = await defer_to_thread(encrypt, self.readkey)
now = time.time() now = time.time()
self._status.accumulate_encrypt_time(now - started) self._status.accumulate_encrypt_time(now - started)