When updating message schema pre-SQLCipher, use legacy save
This commit is contained in:
parent
3b7ee3e2ce
commit
b1c6a5fe19
3 changed files with 22 additions and 12 deletions
|
@ -230,7 +230,7 @@
|
|||
upgradeMessageSchema,
|
||||
maxVersion: MINIMUM_VERSION,
|
||||
BackboneMessage: Whisper.Message,
|
||||
saveMessage: window.Signal.Data.saveMessage,
|
||||
saveMessage: window.Signal.Data.saveLegacyMessage,
|
||||
}
|
||||
);
|
||||
window.log.info(
|
||||
|
@ -251,7 +251,7 @@
|
|||
upgradeMessageSchema,
|
||||
getMessagesNeedingUpgrade:
|
||||
window.Signal.Data.getLegacyMessagesNeedingUpgrade,
|
||||
saveMessage: window.Signal.Data.saveMessage,
|
||||
saveMessage: window.Signal.Data.saveLegacyMessage,
|
||||
maxVersion: MINIMUM_VERSION,
|
||||
});
|
||||
window.log.info('upgradeMessages: upgrade with index', batchWithIndex);
|
||||
|
@ -264,6 +264,16 @@
|
|||
|
||||
await upgradeMessages();
|
||||
|
||||
const db = await Whisper.Database.open();
|
||||
await window.Signal.migrateToSQL({
|
||||
db,
|
||||
clearStores: Whisper.Database.clearStores,
|
||||
handleDOMException: Whisper.Database.handleDOMException,
|
||||
});
|
||||
|
||||
// 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(
|
||||
|
@ -296,16 +306,6 @@
|
|||
}
|
||||
});
|
||||
|
||||
const db = await Whisper.Database.open();
|
||||
await window.Signal.migrateToSQL({
|
||||
db,
|
||||
clearStores: Whisper.Database.clearStores,
|
||||
handleDOMException: Whisper.Database.handleDOMException,
|
||||
});
|
||||
|
||||
// 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.
|
||||
|
||||
// These make key operations available to IPC handlers created in preload.js
|
||||
window.Events = {
|
||||
getDeviceName: () => textsecure.storage.user.getDeviceName(),
|
||||
|
|
|
@ -56,6 +56,9 @@
|
|||
window.hasSignalAccount = number => window.AccountCache[number];
|
||||
|
||||
window.Whisper.Message = Backbone.Model.extend({
|
||||
// Keeping this for legacy upgrade pre-migrate to SQLCipher
|
||||
database: Whisper.Database,
|
||||
storeName: 'messages',
|
||||
initialize(attributes) {
|
||||
if (_.isObject(attributes)) {
|
||||
this.set(
|
||||
|
|
|
@ -35,6 +35,7 @@ module.exports = {
|
|||
removeDB,
|
||||
|
||||
saveMessage,
|
||||
saveLegacyMessage,
|
||||
saveMessages,
|
||||
removeMessage,
|
||||
_removeMessages,
|
||||
|
@ -205,6 +206,12 @@ async function saveMessage(data, { forceSave } = {}) {
|
|||
return id;
|
||||
}
|
||||
|
||||
async function saveLegacyMessage(data, { Message }) {
|
||||
const message = new Message(data);
|
||||
await deferredToPromise(message.save());
|
||||
return message.id;
|
||||
}
|
||||
|
||||
async function saveMessages(arrayOfMessages, { forceSave } = {}) {
|
||||
await channels.saveMessages(_cleanData(arrayOfMessages), { forceSave });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue