WIP: StorageInterface

This commit is contained in:
John Rommel Estropia
2016-03-08 07:55:15 +09:00
parent 34495d7163
commit 2f8c100cb6
6 changed files with 21 additions and 22 deletions

View File

@@ -73,8 +73,7 @@ public extension DataStack {
URL: nil,
options: storage.storeOptions
)
self.updateMetadataForPersistentStore(persistentStore)
storage.internalStore = persistentStore
self.updateMetadataForStorage(storage, persistentStore: persistentStore)
GCDQueue.Main.async {
@@ -147,7 +146,8 @@ public extension DataStack {
let fileManager = NSFileManager.defaultManager()
do {
_ = try? fileManager.createDirectoryAtURL(
try fileManager.createDirectoryAtURL(
fileURL.URLByDeletingLastPathComponent!,
withIntermediateDirectories: true,
attributes: nil
@@ -168,9 +168,9 @@ public extension DataStack {
if storage.resetStoreOnModelMismatch && error.isCoreDataMigrationError {
fileManager.removeSQLiteStoreAtURL(fileURL)
do {
try _ = self.model[metadata].flatMap(storage.eraseStorageAndWait)
try self.addStorageAndWait(storage)
GCDQueue.Main.async {
@@ -282,10 +282,6 @@ public extension DataStack {
options: storage.storeOptions
)
}
catch let error as NSError where error.code == NSFileReadNoSuchFileError && error.domain == NSCocoaErrorDomain {
return []
}
catch {
CoreStore.handleError(
@@ -508,8 +504,6 @@ public extension DataStack {
isDirectory: false
)
try storage.eraseStorageAndWait()
let migrationManager = MigrationManager(
sourceModel: sourceModel,
destinationModel: destinationModel,