unhexlify/hexlify some values in database/storage.py

This commit is contained in:
Lex Berezhny 2018-07-21 14:18:03 -04:00 committed by Jack Robison
parent 971252d5d1
commit 1a3eaf7e6a
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -268,7 +268,7 @@ class SQLiteStorage(WalletDatabase):
blob_hashes = yield self.run_and_return_list(
"select blob_hash from blob where status='finished'"
)
defer.returnValue([bytes.fromhex(blob_hash).decode('latin-1') for blob_hash in blob_hashes])
defer.returnValue([unhexlify(blob_hash) for blob_hash in blob_hashes])
def count_finished_blobs(self):
return self.run_and_return_one_or_none(
@ -492,10 +492,9 @@ class SQLiteStorage(WalletDatabase):
@defer.inlineCallbacks
def save_downloaded_file(self, stream_hash, file_name, download_directory, data_payment_rate):
# touch the closest available file to the file name
file_name = yield open_file_for_writing(bytes.fromhex(download_directory).decode(),
bytes.fromhex(file_name).decode())
file_name = yield open_file_for_writing(unhexlify(download_directory), unhexlify(file_name))
result = yield self.save_published_file(
stream_hash, file_name.encode('hex'), download_directory, data_payment_rate
stream_hash, hexlify(file_name), download_directory, data_payment_rate
)
defer.returnValue(result)