Do not discard migrated profiles in TestFlight (#886)

Users would lose those profiles on downgrade to v2.
This commit is contained in:
Davide 2024-11-17 18:21:37 +01:00 committed by GitHub
parent 12b1784ac2
commit e58726d0af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -40,6 +40,9 @@ struct MigrateView: View {
@EnvironmentObject
private var migrationManager: MigrationManager
@EnvironmentObject
private var iapManager: IAPManager
@Environment(\.dismiss)
private var dismiss
@ -187,12 +190,18 @@ private extension MigrateView {
model.statuses[$0.id] == .done
}
pp_log(.App.migration, .notice, "Migrated \(migrated.count) profiles")
do {
try await migrationManager.deleteMigratableProfiles(withIds: Set(migrated.map(\.id)))
pp_log(.App.migration, .notice, "Discarded \(migrated.count) migrated profiles from old store")
} catch {
pp_log(.App.migration, .error, "Unable to discard migrated profiles: \(error)")
if !iapManager.isRestricted {
do {
try await migrationManager.deleteMigratableProfiles(withIds: Set(migrated.map(\.id)))
pp_log(.App.migration, .notice, "Discarded \(migrated.count) migrated profiles from old store")
} catch {
pp_log(.App.migration, .error, "Unable to discard migrated profiles: \(error)")
}
} else {
pp_log(.App.migration, .notice, "Restricted build, do not discard migrated profiles")
}
model.step = .migrated(migrated)
} catch {
pp_log(.App.migration, .error, "Unable to migrate profiles: \(error)")