Level up to strict Concurrency (#361)

Trigger and resolve some additional Concurrency issues.
This commit is contained in:
Davide De Rosa 2023-09-10 20:36:52 +02:00 committed by GitHub
parent c5cf0ca1d2
commit 7de000148f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 30 additions and 12 deletions

View File

@ -1898,6 +1898,7 @@
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "match Development com.algoritmico.ios.Passepartout catalyst";
SUPPORTS_MACCATALYST = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = targeted;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@ -1924,6 +1925,7 @@
PROVISIONING_PROFILE_SPECIFIER = "match Development com.algoritmico.ios.Passepartout";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "match Development com.algoritmico.ios.Passepartout catalyst";
SUPPORTS_MACCATALYST = YES;
SWIFT_STRICT_CONCURRENCY = targeted;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;

View File

@ -53,8 +53,6 @@ extension ProfileManager {
}
extension ProviderManager {
@MainActor
static let shared = AppContext.shared.providerManager
}

View File

@ -27,6 +27,7 @@ import Foundation
import Intents
import PassepartoutLibrary
@MainActor
final class IntentDispatcher {
private struct Groups {
static let vpn = "VPN"

View File

@ -26,6 +26,7 @@
import Foundation
import PassepartoutLibrary
@MainActor
protocol ProviderProfileAvailability {
var profile: Profile { get }

View File

@ -43,6 +43,7 @@ final class MacBundleDelegate: MacMenuDelegate {
DefaultLightVPNManager()
}
@MainActor
var utils: LightUtils {
DefaultLightUtils()
}

View File

@ -25,7 +25,7 @@
import Combine
import Foundation
import Intents
@preconcurrency import Intents
import IntentsUI
import PassepartoutLibrary

View File

@ -29,6 +29,7 @@ import CoreData
import Foundation
import PassepartoutLibrary
@MainActor
final class PersistenceManager: ObservableObject {
let store: KeyValueStore
@ -80,16 +81,12 @@ final class PersistenceManager: ObservableObject {
extension PersistenceManager {
func eraseCloudKitStore() async {
await MainActor.run {
isErasingCloudKitStore = true
}
isErasingCloudKitStore = true
await Self.eraseCloudKitStore(
fromContainerWithId: ckContainerId,
zoneId: .init(zoneName: ckCoreDataZone)
)
await MainActor.run {
isErasingCloudKitStore = false
}
isErasingCloudKitStore = false
}
// WARNING: this is not running on main actor

View File

@ -27,6 +27,8 @@ import Foundation
import PassepartoutLibrary
extension AddProviderView {
@MainActor
final class ViewModel: ObservableObject {
enum PendingOperation {
case index

View File

@ -329,6 +329,8 @@ private struct EndpointsByAddress: Identifiable {
// MARK: - Bindings
private extension ObservableProfile {
@MainActor
func builderBinding(providerManager: ProviderManager) -> Binding<OpenVPN.ConfigurationBuilder> {
.init {
if self.value.isProvider {

View File

@ -120,6 +120,8 @@ private extension EndpointView.WireGuardView {
// MARK: - Bindings
private extension ObservableProfile {
@MainActor
func builderBinding(providerManager: ProviderManager) -> Binding<WireGuard.ConfigurationBuilder> {
.init {
if self.value.isProvider {

View File

@ -103,7 +103,9 @@ private extension ProfileView.ProviderSection {
Label(L10n.Provider.Preset.title, systemImage: themeProviderPresetImage)
.withTrailingText(currentProviderPreset)
}
Button(action: refreshInfrastructure) {
Button {
refreshInfrastructure()
} label: {
Text(L10n.Profile.Items.Provider.Refresh.caption)
}.withTrailingProgress(when: isRefreshingInfrastructure)
} footer: {

View File

@ -309,6 +309,8 @@ private extension ProviderLocationView.ServerListView {
// MARK: - Bindings
private extension ObservableProfile {
@MainActor
func selectedServerBinding(providerManager: ProviderManager, isPresented: Binding<Bool>) -> Binding<ProviderServer?> {
.init {
guard let serverId = self.value.providerServerId else {

View File

@ -95,6 +95,8 @@ private extension ProviderPresetView {
// MARK: - Bindings
private extension ObservableProfile {
@MainActor
func selectedPresetBinding(providerManager: ProviderManager) -> Binding<ProviderServer.Preset?> {
.init {
guard let serverId = self.value.providerServerId else {

View File

@ -25,6 +25,7 @@
import Foundation
@MainActor
public protocol RateLimited: AnyObject {
associatedtype ActionID: Hashable

View File

@ -27,6 +27,7 @@ import Combine
import Foundation
import PassepartoutCore
@MainActor
public final class ProviderManager: ObservableObject, RateLimited {
private let localProvidersRepository: LocalProvidersRepository

View File

@ -28,6 +28,7 @@ import PassepartoutCore
import PassepartoutProviders
import PassepartoutVPN
@MainActor
extension Profile {
public func providerServer(_ providerManager: ProviderManager) -> ProviderServer? {
guard let serverId = providerServerId else {

View File

@ -133,7 +133,7 @@ extension TunnelKitVPNManagerStrategy {
}
public func reinstate(_ parameters: VPNConfigurationParameters) async throws {
let configuration = try vpnConfiguration(withParameters: parameters)
let configuration = try await vpnConfiguration(withParameters: parameters)
guard let vpnType = configuration.neConfiguration as? VPNProtocolProviding else {
fatalError("Configuration must implement VPNProtocolProviding")
}
@ -154,7 +154,7 @@ extension TunnelKitVPNManagerStrategy {
}
public func connect(_ parameters: VPNConfigurationParameters) async throws {
let configuration = try vpnConfiguration(withParameters: parameters)
let configuration = try await vpnConfiguration(withParameters: parameters)
guard let vpnType = configuration.neConfiguration as? VPNProtocolProviding else {
fatalError("Configuration must implement VPNProtocolProviding")
}
@ -301,6 +301,8 @@ private extension TunnelKitVPNManagerStrategy {
// MARK: Configuration
private extension TunnelKitVPNManagerStrategy {
@MainActor
func vpnConfiguration(withParameters parameters: VPNConfigurationParameters) throws -> TunnelKitVPNConfiguration {
let profile = parameters.profile
do {

View File

@ -30,6 +30,7 @@ import PassepartoutProviders
@testable import PassepartoutProvidersImpl
import XCTest
@MainActor
final class ProvidersTests: XCTestCase {
private var persistence: ProvidersPersistence!