From 11368d5b281dedbebc742a58197b9a3851fbe2c3 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 30 Oct 2020 10:39:22 -0300 Subject: [PATCH] Only prepare group members for migration just before the migration. --- .../ViewControllers/AppSettings/TestingViewController.swift | 2 +- SignalMessaging/groups/GroupsV2Impl.swift | 2 +- SignalMessaging/groups/GroupsV2Migration.swift | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettings/TestingViewController.swift b/Signal/src/ViewControllers/AppSettings/TestingViewController.swift index 82d67d6012..25adb08620 100644 --- a/Signal/src/ViewControllers/AppSettings/TestingViewController.swift +++ b/Signal/src/ViewControllers/AppSettings/TestingViewController.swift @@ -171,7 +171,7 @@ class TestingViewController: OWSTableViewController { let section = OWSTableSection() section.footerTitle = LocalizationNotNeeded("Make sure to force-enable auto-migrations above first.") section.add(OWSTableItem.actionItem(withText: LocalizationNotNeeded("Groups v2: Auto-migrate all v1 groups")) { - GroupsV2Migration.tryToAutoMigrateAllGroups() + GroupsV2Migration.tryToAutoMigrateAllGroups(shouldLimitBatchSize: false) }) contents.addSection(section) } diff --git a/SignalMessaging/groups/GroupsV2Impl.swift b/SignalMessaging/groups/GroupsV2Impl.swift index 1bdb6802f5..c22d746932 100644 --- a/SignalMessaging/groups/GroupsV2Impl.swift +++ b/SignalMessaging/groups/GroupsV2Impl.swift @@ -78,7 +78,7 @@ public class GroupsV2Impl: NSObject, GroupsV2Swift { Self.enqueueRestoreGroupPass() - GroupsV2Migration.tryToAutoMigrateAllGroups() + GroupsV2Migration.tryToAutoMigrateAllGroups(shouldLimitBatchSize: true) } observeNotifications() diff --git a/SignalMessaging/groups/GroupsV2Migration.swift b/SignalMessaging/groups/GroupsV2Migration.swift index 58434fc32c..e900f679d8 100644 --- a/SignalMessaging/groups/GroupsV2Migration.swift +++ b/SignalMessaging/groups/GroupsV2Migration.swift @@ -160,7 +160,7 @@ public extension GroupsV2Migration { return true } - static func tryToAutoMigrateAllGroups() { + static func tryToAutoMigrateAllGroups(shouldLimitBatchSize: Bool) { AssertIsOnMainThread() guard FeatureFlags.groupsV2Migrations else { @@ -211,7 +211,7 @@ public extension GroupsV2Migration { // Check up to N groups on every launch. let maxCheckCount: Int = 50 - if groupThreads.count > maxCheckCount { + if shouldLimitBatchSize, groupThreads.count > maxCheckCount { groupThreads.shuffle() groupThreads = Array(groupThreads.prefix(upTo: maxCheckCount)) }