mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 22:30:34 +01:00
Fix sig abort error
This commit is contained in:
@@ -117,7 +117,7 @@ extension DataStack.ReactiveNamespace {
|
||||
}
|
||||
|
||||
/**
|
||||
Reactive extension for `CoreStore.DataStack`'s `addStorage(...)` API. Asynchronously adds a `LocalStorage` to the stack. Migrations are also initiated by default. The event emits `DataStack.AddStoragePublisher.Progress` `enum` values.
|
||||
Reactive extension for `CoreStore.DataStack`'s `addStorage(...)` API. Asynchronously adds a `LocalStorage` to the stack. Migrations are also initiated by default. The event emits `DataStack.AddStoragePublisher.MigrationProgress` `enum` values.
|
||||
```
|
||||
dataStack.reactive
|
||||
.addStorage(
|
||||
@@ -137,7 +137,7 @@ extension DataStack.ReactiveNamespace {
|
||||
.store(in: &cancellables)
|
||||
```
|
||||
- parameter storage: the local storage
|
||||
- returns: A `DataStack.AddStoragePublisher` that emits a `DataStack.AddStoragePublisher.Progress` value with metadata for migration progress. Note that the `LocalStorage` event value may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
|
||||
- returns: A `DataStack.AddStoragePublisher` that emits a `DataStack.AddStoragePublisher.MigrationProgress` value with metadata for migration progress. Note that the `LocalStorage` event value may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
|
||||
*/
|
||||
public func addStorage<T: LocalStorage>(_ storage: T) -> DataStack.AddStoragePublisher<T> {
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ extension DataStack {
|
||||
|
||||
// MARK: Publisher
|
||||
|
||||
public typealias Output = Progress
|
||||
public typealias Output = MigrationProgress
|
||||
public typealias Failure = CoreStoreError
|
||||
|
||||
public func receive<S: Subscriber>(subscriber: S) where S.Input == Output, S.Failure == Failure {
|
||||
@@ -64,19 +64,19 @@ extension DataStack {
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Progress
|
||||
// MARK: - MigrationProgress
|
||||
|
||||
/**
|
||||
A `Progress` contains info on a `LocalStorage`'s setup progress.
|
||||
A `MigrationProgress` contains info on a `LocalStorage`'s setup progress.
|
||||
|
||||
- SeeAlso: DataStack.reactive.addStorage(_:)
|
||||
*/
|
||||
public enum Progress {
|
||||
public enum MigrationProgress {
|
||||
|
||||
/**
|
||||
The `LocalStorage` is currently being migrated
|
||||
*/
|
||||
case migrating(storage: Storage, progressObject: Foundation.Progress)
|
||||
case migrating(storage: Storage, progressObject: Progress)
|
||||
|
||||
/**
|
||||
The `LocalStorage` has been added to the `DataStack` and is ready for reading and writing
|
||||
@@ -143,7 +143,7 @@ extension DataStack {
|
||||
|
||||
// MARK: FilePrivate
|
||||
|
||||
init(
|
||||
fileprivate init(
|
||||
dataStack: DataStack,
|
||||
storage: Storage,
|
||||
subscriber: S
|
||||
@@ -163,11 +163,13 @@ extension DataStack {
|
||||
|
||||
return
|
||||
}
|
||||
var progress: Foundation.Progress?
|
||||
var progress: Progress? = nil
|
||||
progress = self.dataStack.addStorage(
|
||||
self.storage,
|
||||
completion: { [weak self] result in
|
||||
|
||||
progress?.setProgressHandler(nil)
|
||||
|
||||
guard
|
||||
let self = self,
|
||||
let subscriber = self.subscriber
|
||||
@@ -195,25 +197,24 @@ extension DataStack {
|
||||
}
|
||||
}
|
||||
)
|
||||
guard let progress = progress else {
|
||||
if let progress = progress {
|
||||
|
||||
return
|
||||
}
|
||||
progress.cs_setProgressHandler { [weak self] progress in
|
||||
|
||||
guard
|
||||
let self = self,
|
||||
let subscriber = self.subscriber
|
||||
else {
|
||||
progress.cs_setProgressHandler { [weak self] progress in
|
||||
|
||||
return
|
||||
}
|
||||
_ = subscriber.receive(
|
||||
.migrating(
|
||||
storage: self.storage,
|
||||
progressObject: progress
|
||||
guard
|
||||
let self = self,
|
||||
let subscriber = self.subscriber
|
||||
else {
|
||||
|
||||
return
|
||||
}
|
||||
_ = subscriber.receive(
|
||||
.migrating(
|
||||
storage: self.storage,
|
||||
progressObject: progress
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,27 +77,42 @@ extension Internals {
|
||||
let transformerName = self.transformerName
|
||||
if #available(iOS 12.0, tvOS 12.0, watchOS 5.0, macOS 10.14, *) {
|
||||
|
||||
if transformerName == .secureUnarchiveFromDataTransformerName {
|
||||
switch transformerName {
|
||||
|
||||
case .secureUnarchiveFromDataTransformerName,
|
||||
.isNotNilTransformerName,
|
||||
.isNilTransformerName,
|
||||
.negateBooleanTransformerName:
|
||||
return
|
||||
|
||||
case let transformerName:
|
||||
Self.cachedCoders[transformerName] = self
|
||||
|
||||
Foundation.ValueTransformer.setValueTransformer(
|
||||
self.transformer,
|
||||
forName: transformerName
|
||||
)
|
||||
}
|
||||
}
|
||||
switch transformerName {
|
||||
else {
|
||||
|
||||
switch transformerName {
|
||||
|
||||
case .keyedUnarchiveFromDataTransformerName,
|
||||
.unarchiveFromDataTransformerName,
|
||||
.isNotNilTransformerName,
|
||||
.isNilTransformerName,
|
||||
.negateBooleanTransformerName:
|
||||
return
|
||||
case .keyedUnarchiveFromDataTransformerName,
|
||||
.unarchiveFromDataTransformerName,
|
||||
.isNotNilTransformerName,
|
||||
.isNilTransformerName,
|
||||
.negateBooleanTransformerName:
|
||||
return
|
||||
|
||||
case let transformerName:
|
||||
Self.cachedCoders[transformerName] = self
|
||||
case let transformerName:
|
||||
Self.cachedCoders[transformerName] = self
|
||||
|
||||
Foundation.ValueTransformer.setValueTransformer(
|
||||
self.transformer,
|
||||
forName: transformerName
|
||||
)
|
||||
Foundation.ValueTransformer.setValueTransformer(
|
||||
self.transformer,
|
||||
forName: transformerName
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user