Use @signalapp/sqlcipher

This commit is contained in:
Fedor Indutny
2025-03-12 14:45:54 -07:00
committed by GitHub
parent df7997b313
commit 5a9253bd44
118 changed files with 2497 additions and 1485 deletions

View File

@@ -4,7 +4,7 @@
import { assert } from 'chai';
import { omit } from 'lodash';
import type { WritableDB } from '../../sql/Interface';
import { createDB, updateToVersion } from './helpers';
import { createDB, updateToVersion, explain } from './helpers';
import type { AttachmentDownloadJobType } from '../../types/AttachmentDownload';
import { jsonToObject, objectToJSON, sql } from '../../sql/util';
import { IMAGE_BMP } from '../../types/MIME';
@@ -59,14 +59,14 @@ function insertOldJob(
db.prepare(query).run(params);
}
function getAttachmentDownloadJobs(db: WritableDB) {
function getAttachmentDownloadJobs(db: WritableDB): unknown {
const [query] = sql`
SELECT * FROM attachment_downloads ORDER BY receivedAt DESC;
`;
return db
.prepare(query)
.all()
.all<{ active: number; attachmentJson: string }>()
.map(job => ({
...omit(job, 'attachmentJson'),
active: job.active === 1,
@@ -108,17 +108,13 @@ describe('SQL/updateToSchemaVersion1180', () => {
});
it('uses convering index for summing all pending backup jobs', async () => {
updateToVersion(db, 1180);
const details = db
.prepare(
const details = explain(
db,
sql`
SELECT SUM(ciphertextSize) FROM attachment_downloads
WHERE source = 'backup_import';
`
EXPLAIN QUERY PLAN
SELECT SUM(ciphertextSize) FROM attachment_downloads
WHERE source = 'backup_import';
`
)
.all()
.map(step => step.detail)
.join(', ');
);
assert.strictEqual(
details,
@@ -127,17 +123,13 @@ describe('SQL/updateToSchemaVersion1180', () => {
});
it('uses index for deleting all backup jobs', async () => {
updateToVersion(db, 1180);
const details = db
.prepare(
const details = explain(
db,
sql`
DELETE FROM attachment_downloads
WHERE source = 'backup_import';
`
EXPLAIN QUERY PLAN
DELETE FROM attachment_downloads
WHERE source = 'backup_import';
`
)
.all()
.map(step => step.detail)
.join(', ');
);
assert.strictEqual(
details,