From 339df068a8635f864190c68beedbc58d19089577 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 4 Feb 2025 18:56:51 +0100 Subject: [PATCH] attempt to fix issue where race condition can happen --- LeStorage/ApiCallCollection.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LeStorage/ApiCallCollection.swift b/LeStorage/ApiCallCollection.swift index b132a62..c553212 100644 --- a/LeStorage/ApiCallCollection.swift +++ b/LeStorage/ApiCallCollection.swift @@ -216,7 +216,7 @@ actor ApiCallCollection: SomeCallCollection { /// Returns an APICall instance for the Storable [instance] and an HTTP [method] /// The method updates existing calls or creates a new one - fileprivate func _callForInstance(_ instance: T, method: HTTPMethod) throws -> ApiCall? { + fileprivate func _callForInstance(_ instance: T, method: HTTPMethod) async throws -> ApiCall? { if let existingCall = self.items.first(where: { $0.dataId == instance.stringId }) { switch method { @@ -293,7 +293,7 @@ actor ApiCallCollection: SomeCallCollection { /// Initiates the process of sending the data with the server fileprivate func _synchronize(_ instance: T, method: HTTPMethod) async throws -> V? { - if let apiCall = try self._callForInstance(instance, method: method) { + if let apiCall = try await self._callForInstance(instance, method: method) { self._prepareCall(apiCall: apiCall) return try await self._executeApiCall(apiCall) } else {