Perform client store optimizations when migrating versions.

This commit is contained in:
Stefan Ceriu
2025-12-18 16:36:54 +02:00
committed by Stefan Ceriu
parent 57cd5dd794
commit 8a1d0fe8b1
4 changed files with 80 additions and 0 deletions
@@ -4642,6 +4642,71 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
return clearCachesReturnValue
}
}
//MARK: - optimizeStores
var optimizeStoresUnderlyingCallsCount = 0
var optimizeStoresCallsCount: Int {
get {
if Thread.isMainThread {
return optimizeStoresUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = optimizeStoresUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
optimizeStoresUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
optimizeStoresUnderlyingCallsCount = newValue
}
}
}
}
var optimizeStoresCalled: Bool {
return optimizeStoresCallsCount > 0
}
var optimizeStoresUnderlyingReturnValue: Result<Void, ClientProxyError>!
var optimizeStoresReturnValue: Result<Void, ClientProxyError>! {
get {
if Thread.isMainThread {
return optimizeStoresUnderlyingReturnValue
} else {
var returnValue: Result<Void, ClientProxyError>? = nil
DispatchQueue.main.sync {
returnValue = optimizeStoresUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
optimizeStoresUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
optimizeStoresUnderlyingReturnValue = newValue
}
}
}
}
var optimizeStoresClosure: (() async -> Result<Void, ClientProxyError>)?
@discardableResult
func optimizeStores() async -> Result<Void, ClientProxyError> {
optimizeStoresCallsCount += 1
if let optimizeStoresClosure = optimizeStoresClosure {
return await optimizeStoresClosure()
} else {
return optimizeStoresReturnValue
}
}
//MARK: - fetchMediaPreviewConfiguration
var fetchMediaPreviewConfigurationUnderlyingCallsCount = 0