From a03ee52c7082ef02abd2d33107d63189bc8c001a Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 5 Dec 2024 16:32:05 +0100 Subject: [PATCH] Fix code for logging reset --- LeStorage/StoreCenter.swift | 7 +++++-- LeStorage/StoredCollection.swift | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/LeStorage/StoreCenter.swift b/LeStorage/StoreCenter.swift index 4fed337..96bc011 100644 --- a/LeStorage/StoreCenter.swift +++ b/LeStorage/StoreCenter.swift @@ -252,10 +252,13 @@ public class StoreCenter { } public func resetLoggingCollections() { - self._failedAPICallsCollection?.reset() - self._logs?.reset() + Task { do { + try FileManager.default.removeItem(at: Log.urlForJSONFile()) + try FileManager.default.removeItem(at: FailedAPICall.urlForJSONFile()) + + let facApiCallCollection: ApiCallCollection = try self.apiCallCollection() await facApiCallCollection.reset() let logApiCallCollection: ApiCallCollection = try self.apiCallCollection() diff --git a/LeStorage/StoredCollection.swift b/LeStorage/StoredCollection.swift index c7ff2aa..aefa7a5 100644 --- a/LeStorage/StoredCollection.swift +++ b/LeStorage/StoredCollection.swift @@ -124,7 +124,11 @@ public class StoredCollection: RandomAccessCollection, SomeCollecti if self.asynchronousIO { Task(priority: .high) { - try self._decodeJSONFile() + do { + try self._decodeJSONFile() + } catch { + Logger.error(error) + } } } else { try self._decodeJSONFile()