|
|
|
@ -500,8 +500,8 @@ public class StoredCollection<T: Storable>: SomeCollection { |
|
|
|
|
|
|
|
|
|
|
|
/// Schedules a write operation |
|
|
|
/// Schedules a write operation |
|
|
|
fileprivate func _scheduleWrite() { |
|
|
|
fileprivate func _scheduleWrite() { |
|
|
|
DispatchQueue(label: "lestorage.queue.write", qos: .utility).asyncAndWait { |
|
|
|
self._cleanTimer() |
|
|
|
self._cleanTimer() |
|
|
|
DispatchQueue.main.async { |
|
|
|
self._writingTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(self._write), userInfo: nil, repeats: false) |
|
|
|
self._writingTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(self._write), userInfo: nil, repeats: false) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -513,13 +513,15 @@ public class StoredCollection<T: Storable>: SomeCollection { |
|
|
|
|
|
|
|
|
|
|
|
/// Writes all the items as a json array inside a file |
|
|
|
/// Writes all the items as a json array inside a file |
|
|
|
@objc fileprivate func _write() { |
|
|
|
@objc fileprivate func _write() { |
|
|
|
do { |
|
|
|
DispatchQueue(label: "lestorage.queue.write", qos: .utility).async { |
|
|
|
let jsonString: String = try self.items.jsonString() |
|
|
|
do { |
|
|
|
try self.store.write(content: jsonString, fileName: T.fileName()) |
|
|
|
let jsonString: String = try self.items.jsonString() |
|
|
|
} catch { |
|
|
|
try self.store.write(content: jsonString, fileName: T.fileName()) |
|
|
|
Logger.error(error) |
|
|
|
} catch { |
|
|
|
self.storeCenter.log( |
|
|
|
Logger.error(error) |
|
|
|
message: "write failed for \(T.resourceName()): \(error.localizedDescription)") |
|
|
|
self.storeCenter.log( |
|
|
|
|
|
|
|
message: "write failed for \(T.resourceName()): \(error.localizedDescription)") |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
self._cleanTimer() |
|
|
|
self._cleanTimer() |
|
|
|
} |
|
|
|
} |
|
|
|
|