Drop unnecessary async from migration code

Providers are not fetched at migration time, they only are after
opening a profile (marked non-ready until then).

Still retain Task for migration to be executed asynchronously.
This commit is contained in:
Davide De Rosa 2022-05-05 11:02:40 +02:00
parent 57f7b15aa2
commit 9984c56084
3 changed files with 6 additions and 6 deletions

View File

@ -135,7 +135,7 @@ extension OrganizerView {
private func performMigrationsIfNeeded() {
Task {
await AppManager.shared.doMigrations(profileManager)
AppManager.shared.doMigrations(profileManager)
}
}
}

View File

@ -52,7 +52,7 @@ extension AppManager {
return "group.com.algoritmico.Passepartout"
}
func doMigrateToV2() async -> [Profile] {
func doMigrateToV2() -> [Profile] {
var migrated: [Profile] = []
pp_log.info("Migrating data to v2")
@ -126,7 +126,7 @@ extension AppManager {
let json = try provider.asJSON()
// pp_log.error(json)
let result = try await migratedV1Profile(csJSON, providerMap: json)
let result = try migratedV1Profile(csJSON, providerMap: json)
// pp_log.info(result.profile)
// print(">>> Account: \(result.profile.username) -> \(result.password)")
@ -212,7 +212,7 @@ extension AppManager {
// presetId
// favoriteGroupIds
//
private func migratedV1Profile(_ cs: Map, providerMap: Map) async throws -> Profile {
private func migratedV1Profile(_ cs: Map, providerMap: Map) throws -> Profile {
guard let name = providerMap["name"] as? String else {
throw MigrationError.missingProviderName
}

View File

@ -106,11 +106,11 @@ public class AppManager: ObservableObject {
CoreConfiguration.masksPrivateData = masksPrivateData
}
public func doMigrations(_ profileManager: ProfileManager) async {
public func doMigrations(_ profileManager: ProfileManager) {
// profileManager.removeAllProfiles()
guard didMigrateToV2 else {
isDoingMigrations = true
let migrated = await doMigrateToV2()
let migrated = doMigrateToV2()
if !migrated.isEmpty {
pp_log.info("Migrating \(migrated.count) profiles")
migrated.forEach {