mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-26 11:28:08 +01:00
Use @signalapp/sqlcipher
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user