Skip to content

Commit

Permalink
Keep object stores after conversations migrate to SQLCipher
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Oct 15, 2018
1 parent bc0ec92 commit 7532f39
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
22 changes: 1 addition & 21 deletions js/background.js
Expand Up @@ -131,10 +131,7 @@
deleteAttachmentData,
getCurrentVersion,
} = window.Signal.Migrations;
const {
Migrations0DatabaseWithAttachmentData,
Migrations1DatabaseWithoutAttachmentData,
} = window.Signal.Migrations;
const { Migrations0DatabaseWithAttachmentData } = window.Signal.Migrations;
const { Views } = window.Signal;

// Implicitly used in `indexeddb-backbonejs-adapter`:
Expand Down Expand Up @@ -391,20 +388,6 @@

Views.Initialization.setMessage(window.i18n('optimizingApplication'));

window.log.info('Running cleanup IndexedDB migrations...');
await Whisper.Database.close();

// Now we clean up IndexedDB database after extracting data from it
await Migrations1DatabaseWithoutAttachmentData.run({
Backbone,
logger: window.log,
});

const latestDBVersion = _.last(
Migrations1DatabaseWithoutAttachmentData.migrations
).version;
Whisper.Database.migrations[0].version = latestDBVersion;

window.log.info('Cleanup: starting...');
const messagesForCleanup = await window.Signal.Data.getOutgoingWithoutExpiresAt(
{
Expand Down Expand Up @@ -452,9 +435,6 @@

Views.Initialization.setMessage(window.i18n('loading'));

// Note: We are not invoking the second set of IndexedDB migrations because it is
// likely that any future migrations will simply extracting things from IndexedDB.

idleDetector = new IdleDetector();
let isMigrationWithIndexComplete = false;
window.log.info(
Expand Down
Expand Up @@ -165,6 +165,17 @@ const migrations = [
next();
},
},
{
version: 19,
migrate(transaction, next) {
window.log.info('Migration 19');

// Empty because we don't want to cause incompatibility with users who have already
// run migration 19 when it was the object store removal.

next();
},
},
];

const database = {
Expand Down
Expand Up @@ -6,12 +6,12 @@ const db = require('../database');
const settings = require('../settings');
const { runMigrations } = require('./run_migrations');

// These are cleanup migrations, to be run after migration to SQLCipher
// These are migrations for after the SQLCipher migration, currently not running
exports.migrations = [
{
version: 19,
version: 20,
migrate(transaction, next) {
window.log.info('Migration 19');
window.log.info('Migration 20');
window.log.info(
'Removing messages, unprocessed, and conversations object stores'
);
Expand Down

0 comments on commit 7532f39

Please sign in to comment.