perf: move encryption/decryption to a separate thread
This commit is contained in:
parent
0b337a13a4
commit
b7c7e002eb
16 changed files with 310 additions and 147 deletions
|
@ -9,7 +9,7 @@ export class EncryptExistingMessages1600283341726 implements MigrationInterface
|
|||
// 2. Encrypt all permanent messages
|
||||
const messages = await queryRunner.query("SELECT id, data FROM messages");
|
||||
for (const message of messages) {
|
||||
const encryptedData = encrypt(message.data);
|
||||
const encryptedData = await encrypt(message.data);
|
||||
await queryRunner.query("UPDATE messages SET data = ? WHERE id = ?", [encryptedData, message.id]);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ export class EncryptExistingMessages1600283341726 implements MigrationInterface
|
|||
// Decrypt all messages
|
||||
const messages = await queryRunner.query("SELECT id, data FROM messages");
|
||||
for (const message of messages) {
|
||||
const decryptedData = decrypt(message.data);
|
||||
const decryptedData = await decrypt(message.data);
|
||||
await queryRunner.query("UPDATE messages SET data = ? WHERE id = ?", [decryptedData, message.id]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ export class EncryptArchives1600285077890 implements MigrationInterface {
|
|||
public async up(queryRunner: QueryRunner): Promise<any> {
|
||||
const archives = await queryRunner.query("SELECT id, body FROM archives");
|
||||
for (const archive of archives) {
|
||||
const encryptedBody = encrypt(archive.body);
|
||||
const encryptedBody = await encrypt(archive.body);
|
||||
await queryRunner.query("UPDATE archives SET body = ? WHERE id = ?", [encryptedBody, archive.id]);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ export class EncryptArchives1600285077890 implements MigrationInterface {
|
|||
public async down(queryRunner: QueryRunner): Promise<any> {
|
||||
const archives = await queryRunner.query("SELECT id, body FROM archives");
|
||||
for (const archive of archives) {
|
||||
const decryptedBody = decrypt(archive.body);
|
||||
const decryptedBody = await decrypt(archive.body);
|
||||
await queryRunner.query("UPDATE archives SET body = ? WHERE id = ?", [decryptedBody, archive.id]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue