mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-04 07:10:09 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f25879b6fe | ||
|
|
8fa3109e91 | ||
|
|
808e8ff97a | ||
|
|
30685d4355 | ||
|
|
7152962026 | ||
|
|
91735e38d1 | ||
|
|
333a50ad9e | ||
|
|
b7a602fc67 | ||
|
|
2ff7ecef96 |
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "CoreStore"
|
||||
s.version = "5.1.1"
|
||||
s.version = "5.2.0"
|
||||
s.swift_version = "4.1"
|
||||
s.license = "MIT"
|
||||
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
|
||||
|
||||
@@ -192,7 +192,7 @@ class ObjectObserverDemoViewController: UIViewController, ObjectObserver {
|
||||
|
||||
self.saturationSlider?.value = palette.saturation.value
|
||||
}
|
||||
if changedKeys == nil || changedKeys?.contains(String(keyPath: \Palette.hue)) == true {
|
||||
if changedKeys == nil || changedKeys?.contains(String(keyPath: \Palette.brightness)) == true {
|
||||
|
||||
self.brightnessSlider?.value = palette.brightness.value
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>5.1.1</string>
|
||||
<string>5.2.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -708,9 +708,9 @@ public extension DataStack {
|
||||
var fakeProgress: Float = 0
|
||||
|
||||
var recursiveCheck: () -> Void = {}
|
||||
recursiveCheck = {
|
||||
recursiveCheck = { [weak timerQueue] in
|
||||
|
||||
guard fakeProgress < 1 else {
|
||||
guard let timerQueue = timerQueue, fakeProgress < 1 else {
|
||||
|
||||
return
|
||||
}
|
||||
@@ -739,13 +739,13 @@ public extension DataStack {
|
||||
|
||||
fakeProgress = 1
|
||||
}
|
||||
try storage.cs_finalizeStorageAndWait(soureModelHint: destinationModel)
|
||||
_ = try? storage.cs_finalizeStorageAndWait(soureModelHint: destinationModel)
|
||||
progress.completedUnitCount = progress.totalUnitCount
|
||||
return
|
||||
}
|
||||
catch {
|
||||
|
||||
throw CoreStoreError(error)
|
||||
// Lightweight migration failed somehow. Proceed using InferedMappingModel below
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,6 +760,11 @@ public extension DataStack {
|
||||
attributes: nil
|
||||
)
|
||||
|
||||
let externalStorageFolderName = ".\(fileURL.deletingPathExtension().lastPathComponent)_SUPPORT"
|
||||
let temporaryExternalStorageURL = temporaryDirectoryURL.appendingPathComponent(
|
||||
externalStorageFolderName,
|
||||
isDirectory: true
|
||||
)
|
||||
let temporaryFileURL = temporaryDirectoryURL.appendingPathComponent(
|
||||
fileURL.lastPathComponent,
|
||||
isDirectory: false
|
||||
@@ -796,25 +801,22 @@ public extension DataStack {
|
||||
throw CoreStoreError(error)
|
||||
}
|
||||
|
||||
let externalStorageDirName = "." + fileURL.deletingPathExtension().lastPathComponent + "_SUPPORT"
|
||||
let temporaryExternalStorageURL = temporaryDirectoryURL.appendingPathComponent(
|
||||
externalStorageDirName,
|
||||
isDirectory: true
|
||||
)
|
||||
do {
|
||||
|
||||
try fileManager.replaceItem(
|
||||
at: fileURL as URL,
|
||||
at: fileURL,
|
||||
withItemAt: temporaryFileURL,
|
||||
backupItemName: nil,
|
||||
options: [],
|
||||
resultingItemURL: nil
|
||||
)
|
||||
|
||||
if fileManager.fileExists(atPath: temporaryExternalStorageURL.path) {
|
||||
let extenralStorageURL = fileURL.deletingLastPathComponent().appendingPathComponent(externalStorageDirName, isDirectory: true)
|
||||
|
||||
let externalStorageURL = fileURL
|
||||
.deletingLastPathComponent()
|
||||
.appendingPathComponent(externalStorageFolderName, isDirectory: true)
|
||||
try fileManager.replaceItem(
|
||||
at: extenralStorageURL as URL,
|
||||
at: externalStorageURL,
|
||||
withItemAt: temporaryExternalStorageURL,
|
||||
backupItemName: nil,
|
||||
options: [],
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>5.1.1</string>
|
||||
<string>5.2.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -42,7 +42,10 @@ internal final class MigrationManager: NSMigrationManager, ProgressReporting {
|
||||
return
|
||||
}
|
||||
let progress = self.progress
|
||||
progress.completedUnitCount = Int64(Float(progress.totalUnitCount) * self.migrationProgress)
|
||||
progress.completedUnitCount = max(
|
||||
progress.completedUnitCount,
|
||||
Int64(Float(progress.totalUnitCount) * self.migrationProgress)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -150,7 +150,15 @@ public final class SQLiteStore: LocalStorage {
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
```
|
||||
*/
|
||||
public let storeOptions: [AnyHashable: Any]? = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
public let storeOptions: [AnyHashable: Any]? = autoreleasepool {
|
||||
|
||||
var storeOptions: [AnyHashable: Any] = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
if #available(iOS 11.0, OSX 10.13, tvOSApplicationExtension 11.0, watchOSApplicationExtension 4.0, *) {
|
||||
|
||||
storeOptions[NSBinaryStoreInsecureDecodingCompatibilityOption] = true
|
||||
}
|
||||
return storeOptions
|
||||
}
|
||||
|
||||
/**
|
||||
Do not call directly. Used by the `DataStack` internally.
|
||||
@@ -212,11 +220,13 @@ public final class SQLiteStore: LocalStorage {
|
||||
|
||||
_ = try withExtendedLifetime(NSPersistentStoreCoordinator(managedObjectModel: soureModelHint)) { (coordinator: NSPersistentStoreCoordinator) in
|
||||
|
||||
var storeOptions = self.storeOptions ?? [:]
|
||||
storeOptions[NSSQLitePragmasOption] = ["journal_mode": "DELETE"]
|
||||
try coordinator.addPersistentStore(
|
||||
ofType: type(of: self).storeType,
|
||||
configurationName: self.configuration,
|
||||
at: fileURL,
|
||||
options: [NSSQLitePragmasOption: ["journal_mode": "DELETE"]]
|
||||
options: storeOptions
|
||||
)
|
||||
}
|
||||
_ = try? FileManager.default.removeItem(atPath: "\(self.fileURL.path)-shm")
|
||||
@@ -276,11 +286,13 @@ public final class SQLiteStore: LocalStorage {
|
||||
if let soureModel = soureModelHint ?? NSManagedObjectModel.mergedModel(from: nil, forStoreMetadata: metadata) {
|
||||
|
||||
let journalUpdatingCoordinator = NSPersistentStoreCoordinator(managedObjectModel: soureModel)
|
||||
var storeOptions = self.storeOptions ?? [:]
|
||||
storeOptions[NSSQLitePragmasOption] = ["journal_mode": "DELETE"]
|
||||
let store = try journalUpdatingCoordinator.addPersistentStore(
|
||||
ofType: type(of: self).storeType,
|
||||
configurationName: self.configuration,
|
||||
at: fileURL,
|
||||
options: [NSSQLitePragmasOption: ["journal_mode": "DELETE"]]
|
||||
options: storeOptions
|
||||
)
|
||||
try journalUpdatingCoordinator.remove(store)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user