Increment and store message migration attempts
This commit is contained in:
parent
d547ef362e
commit
63679f5af6
4 changed files with 67 additions and 20 deletions
|
@ -850,7 +850,8 @@ export async function startApp(): Promise<void> {
|
|||
`Starting background data migration. Target version: ${Message.CURRENT_SCHEMA_VERSION}`
|
||||
);
|
||||
idleDetector.on('idle', async () => {
|
||||
const NUM_MESSAGES_PER_BATCH = 1;
|
||||
const NUM_MESSAGES_PER_BATCH = 100;
|
||||
const BATCH_DELAY = 5 * durations.SECOND;
|
||||
|
||||
if (!isMigrationWithIndexComplete) {
|
||||
const batchWithIndex = await migrateMessageData({
|
||||
|
@ -858,15 +859,22 @@ export async function startApp(): Promise<void> {
|
|||
upgradeMessageSchema,
|
||||
getMessagesNeedingUpgrade:
|
||||
window.Signal.Data.getMessagesNeedingUpgrade,
|
||||
saveMessage: window.Signal.Data.saveMessage,
|
||||
saveMessages: window.Signal.Data.saveMessages,
|
||||
});
|
||||
log.info('Upgrade message schema (with index):', batchWithIndex);
|
||||
isMigrationWithIndexComplete = batchWithIndex.done;
|
||||
}
|
||||
|
||||
idleDetector.stop();
|
||||
|
||||
if (isMigrationWithIndexComplete) {
|
||||
log.info('Background migration complete. Stopping idle detector.');
|
||||
idleDetector.stop();
|
||||
} else {
|
||||
log.info('Background migration not complete. Pausing idle detector.');
|
||||
|
||||
setTimeout(() => {
|
||||
idleDetector.start();
|
||||
}, BATCH_DELAY);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue