From 164e63363ca81a9b7cd1577d1fb28f4aa2be7943 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 22 May 2024 17:58:03 +0200 Subject: [PATCH] Remove file deletion error --- LeStorage/Services.swift | 1 - LeStorage/StoredCollection.swift | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/LeStorage/Services.swift b/LeStorage/Services.swift index 89854eb..3ef1118 100644 --- a/LeStorage/Services.swift +++ b/LeStorage/Services.swift @@ -207,7 +207,6 @@ public class Services { request.httpBody = apiCall.body.data(using: .utf8) request.setValue("application/json", forHTTPHeaderField: "Content-Type") - if let method = HTTPMethod(rawValue: apiCall.method), self._isTokenRequired(type: T.self, method: method) { do { let token = try self.keychainStore.getToken() diff --git a/LeStorage/StoredCollection.swift b/LeStorage/StoredCollection.swift index 737f4c0..b758845 100644 --- a/LeStorage/StoredCollection.swift +++ b/LeStorage/StoredCollection.swift @@ -352,7 +352,9 @@ public class StoredCollection: RandomAccessCollection, SomeCollecti do { let url: URL = try self._urlForJSONFile() - try FileManager.default.removeItem(at: url) + if FileManager.default.fileExists(atPath: url.path()) { + try FileManager.default.removeItem(at: url) + } } catch { Logger.error(error) }