Remove messages/conversations/unprocessed IndexedDB object stores
This commit is contained in:
parent
e39c999932
commit
2060118e85
2 changed files with 43 additions and 11 deletions
|
@ -131,7 +131,10 @@
|
||||||
deleteAttachmentData,
|
deleteAttachmentData,
|
||||||
getCurrentVersion,
|
getCurrentVersion,
|
||||||
} = window.Signal.Migrations;
|
} = window.Signal.Migrations;
|
||||||
const { Migrations0DatabaseWithAttachmentData } = window.Signal.Migrations;
|
const {
|
||||||
|
Migrations0DatabaseWithAttachmentData,
|
||||||
|
Migrations1DatabaseWithoutAttachmentData,
|
||||||
|
} = window.Signal.Migrations;
|
||||||
const { Views } = window.Signal;
|
const { Views } = window.Signal;
|
||||||
|
|
||||||
// Implicitly used in `indexeddb-backbonejs-adapter`:
|
// Implicitly used in `indexeddb-backbonejs-adapter`:
|
||||||
|
@ -388,6 +391,23 @@
|
||||||
|
|
||||||
Views.Initialization.setMessage(window.i18n('optimizingApplication'));
|
Views.Initialization.setMessage(window.i18n('optimizingApplication'));
|
||||||
|
|
||||||
|
window.log.info('Running cleanup IndexedDB migrations...');
|
||||||
|
// Close all previous connections to the database first
|
||||||
|
await Whisper.Database.close();
|
||||||
|
|
||||||
|
// Now we clean up IndexedDB database after extracting data from it
|
||||||
|
await Migrations1DatabaseWithoutAttachmentData.run({
|
||||||
|
Backbone,
|
||||||
|
logger: window.log,
|
||||||
|
});
|
||||||
|
|
||||||
|
await Whisper.Database.close();
|
||||||
|
|
||||||
|
const latestDBVersion = _.last(
|
||||||
|
Migrations1DatabaseWithoutAttachmentData.migrations
|
||||||
|
).version;
|
||||||
|
Whisper.Database.migrations[0].version = latestDBVersion;
|
||||||
|
|
||||||
window.log.info('Cleanup: starting...');
|
window.log.info('Cleanup: starting...');
|
||||||
const messagesForCleanup = await window.Signal.Data.getOutgoingWithoutExpiresAt(
|
const messagesForCleanup = await window.Signal.Data.getOutgoingWithoutExpiresAt(
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,25 +1,37 @@
|
||||||
/* global window */
|
/* global window */
|
||||||
|
|
||||||
const { last } = require('lodash');
|
const { last, includes } = require('lodash');
|
||||||
|
|
||||||
const db = require('../database');
|
const { open } = require('../database');
|
||||||
const settings = require('../settings');
|
const settings = require('../settings');
|
||||||
const { runMigrations } = require('./run_migrations');
|
const { runMigrations } = require('./run_migrations');
|
||||||
|
|
||||||
// These are migrations for after the SQLCipher migration, currently not running
|
// These are cleanup migrations, to be run after migration to SQLCipher
|
||||||
exports.migrations = [
|
exports.migrations = [
|
||||||
{
|
{
|
||||||
version: 20,
|
version: 20,
|
||||||
migrate(transaction, next) {
|
migrate(transaction, next) {
|
||||||
window.log.info('Migration 20');
|
window.log.info('Migration 20');
|
||||||
window.log.info(
|
|
||||||
'Removing messages, unprocessed, and conversations object stores'
|
const { db } = transaction;
|
||||||
);
|
|
||||||
|
|
||||||
// This should be run after things are migrated to SQLCipher
|
// This should be run after things are migrated to SQLCipher
|
||||||
transaction.db.deleteObjectStore('messages');
|
|
||||||
transaction.db.deleteObjectStore('unprocessed');
|
// We check for existence first, because this removal was present in v1.17.0.beta.1,
|
||||||
transaction.db.deleteObjectStore('conversations');
|
// but reverted in v1.17.0-beta.3
|
||||||
|
|
||||||
|
if (includes(db.objectStoreNames, 'messages')) {
|
||||||
|
window.log.info('Removing messages store');
|
||||||
|
db.deleteObjectStore('messages');
|
||||||
|
}
|
||||||
|
if (includes(db.objectStoreNames, 'unprocessed')) {
|
||||||
|
window.log.info('Removing unprocessed store');
|
||||||
|
db.deleteObjectStore('unprocessed');
|
||||||
|
}
|
||||||
|
if (includes(db.objectStoreNames, 'conversations')) {
|
||||||
|
window.log.info('Removing conversations store');
|
||||||
|
db.deleteObjectStore('conversations');
|
||||||
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
|
@ -48,7 +60,7 @@ exports.run = async ({ Backbone, logger } = {}) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getStatus = async ({ database } = {}) => {
|
exports.getStatus = async ({ database } = {}) => {
|
||||||
const connection = await db.open(database.id, database.version);
|
const connection = await open(database.id, database.version);
|
||||||
const isAttachmentMigrationComplete = await settings.isAttachmentMigrationComplete(
|
const isAttachmentMigrationComplete = await settings.isAttachmentMigrationComplete(
|
||||||
connection
|
connection
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue