def decompress_and_decrypt_db(self, password: str, encrypted_data: B64EncodedString) -> None: """Decrypt and decompress the encrypted data we receive from the server If successful then replace our local Database May Raise: - UnableToDecryptRemoteData due to decrypt() - DBUpgradeError if the rotki DB version is newer than the software or there is a DB upgrade and there is an error. - SystemPermissionError if the DB file permissions are not correct """ log.info('Decompress and decrypt DB') # First make a backup of the DB we are about to replace date = timestamp_to_date(ts=ts_now(), formatstr='%Y_%m_%d_%H_%M_%S') shutil.copyfile( self.data_directory / self.username / 'rotkehlchen.db', self.data_directory / self.username / f'rotkehlchen_db_{date}.backup', ) decrypted_data = decrypt(password.encode(), encrypted_data) decompressed_data = zlib.decompress(decrypted_data) self.db.import_unencrypted(decompressed_data, password)
def decompress_and_decrypt_db(self, password, encrypted_data): """ Decrypt and decompress the encrypted data we receive from the server If succesfull then replace our local Database""" decrypted_data = decrypt(password.encode(), encrypted_data) decompressed_data = zlib.decompress(decrypted_data) self.db.import_unencrypted(decompressed_data, password)
def decompress_and_decrypt_db(self, password: str, encrypted_data: bytes) -> None: """Decrypt and decompress the encrypted data we receive from the server If successful then replace our local Database""" log.info('Decompress and decrypt DB') decrypted_data = decrypt(password.encode(), encrypted_data) decompressed_data = zlib.decompress(decrypted_data) self.db.import_unencrypted(decompressed_data, password)
def decompress_and_decrypt_db(self, password: str, encrypted_data: str) -> None: """Decrypt and decompress the encrypted data we receive from the server If successful then replace our local Database""" log.info('Decompress and decrypt DB') # First make a backup of the DB we are about to replace date = tsToDate(ts=ts_now(), formatstr='%d_%m_%Y_%H_%M_%S') shutil.copyfile( os.path.join(self.data_directory, self.username, 'rotkehlchen.db'), os.path.join(self.data_directory, self.username, f'rotkehlchen_db_{date}.backup'), ) decrypted_data = decrypt(password.encode(), encrypted_data) decompressed_data = zlib.decompress(decrypted_data) self.db.import_unencrypted(decompressed_data, password)