diff --git a/LeStorage/Store.swift b/LeStorage/Store.swift index 89d632b..00c50e7 100644 --- a/LeStorage/Store.swift +++ b/LeStorage/Store.swift @@ -240,7 +240,6 @@ open class Store { /// Loads all synchronized collection with server data if they don't already have a local file public func loadCollectionsFromServerIfNoFile() { for collection in self._collections.values { -// Logger.log("Load \(name)") if collection.synchronized { Task { do { diff --git a/LeStorage/StoreCenter.swift b/LeStorage/StoreCenter.swift index 3a84cf0..b7d52d6 100644 --- a/LeStorage/StoreCenter.swift +++ b/LeStorage/StoreCenter.swift @@ -354,7 +354,6 @@ public class StoreCenter { public func destroyStore(identifier: String) { let directory = "\(Store.storageDirectory)/\(identifier)" FileManager.default.deleteDirectoryInDocuments(directoryName: directory) - self._stores.removeValue(forKey: identifier) } diff --git a/LeStorage/StoredCollection.swift b/LeStorage/StoredCollection.swift index bc04ba3..10ad76e 100644 --- a/LeStorage/StoredCollection.swift +++ b/LeStorage/StoredCollection.swift @@ -190,12 +190,13 @@ public class StoredCollection: RandomAccessCollection, SomeCollecti do { let items: [T] = try await self._store.getItems() if items.count > 0 { - try self._addOrUpdate(contentOfs: items, shouldSync: false) + DispatchQueue.main.async { + self._addOrUpdate(contentOfs: items, shouldSync: false) + } } } catch { Logger.error(error) } - self._setAsLoaded() } /// Loads the collection using the server data only if the collection file doesn't exists @@ -279,16 +280,16 @@ public class StoredCollection: RandomAccessCollection, SomeCollecti /// Adds or update a sequence of elements public func addOrUpdate(contentOfs sequence: any Sequence) throws { - try self._addOrUpdate(contentOfs: sequence) + self._addOrUpdate(contentOfs: sequence) } /// Adds or update a sequence of elements without synchronizing it func addOrUpdateNoSync(contentOfs sequence: any Sequence) throws { - try self._addOrUpdate(contentOfs: sequence, shouldSync: false) + self._addOrUpdate(contentOfs: sequence, shouldSync: false) } /// Inserts or updates all items in the sequence - fileprivate func _addOrUpdate(contentOfs sequence: any Sequence, shouldSync: Bool = true) throws { + fileprivate func _addOrUpdate(contentOfs sequence: any Sequence, shouldSync: Bool = true) { defer { self._hasChanged = true } diff --git a/LeStorage/Utils/Codable+Extensions.swift b/LeStorage/Utils/Codable+Extensions.swift index f9fcbd0..5bd1c8d 100644 --- a/LeStorage/Utils/Codable+Extensions.swift +++ b/LeStorage/Utils/Codable+Extensions.swift @@ -10,7 +10,7 @@ import Foundation fileprivate var jsonEncoder: JSONEncoder = { let encoder = JSONEncoder() encoder.keyEncodingStrategy = .convertToSnakeCase - #if _DEBUG_OPTIONS + #if DEBUG encoder.outputFormatting = .prettyPrinted #endif encoder.dateEncodingStrategy = .iso8601 diff --git a/LeStorage/Utils/Logger.swift b/LeStorage/Utils/Logger.swift index 8af0b7a..4d79490 100644 --- a/LeStorage/Utils/Logger.swift +++ b/LeStorage/Utils/Logger.swift @@ -40,7 +40,7 @@ import Foundation @objc static public func crashLogging(_ message: String, file: String = #file, function: String = #function, line: Int = #line) { let fileName: String = file.components(separatedBy: "/").last ?? file - #if _DEBUG_OPTIONS + #if DEBUG NSLogv("%@.%i.%@: %@", getVaList([fileName, line, function, message])) #else //Crashlytics.crashlytics().log(format: "%@.%i.%@: %@", arguments: getVaList([fileName, line, function, message]))