mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-27 03:41:29 +01:00
Use InferredMappingModel in case lightweight migration fails for some reason
This commit is contained in:
@@ -739,13 +739,13 @@ public extension DataStack {
|
|||||||
|
|
||||||
fakeProgress = 1
|
fakeProgress = 1
|
||||||
}
|
}
|
||||||
try storage.cs_finalizeStorageAndWait(soureModelHint: destinationModel)
|
_ = try? storage.cs_finalizeStorageAndWait(soureModelHint: destinationModel)
|
||||||
progress.completedUnitCount = progress.totalUnitCount
|
progress.completedUnitCount = progress.totalUnitCount
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
|
||||||
throw CoreStoreError(error)
|
// Lightweight migration failed somehow. Proceed using InferedMappingModel below
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,6 +760,11 @@ public extension DataStack {
|
|||||||
attributes: nil
|
attributes: nil
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let externalStorageFolderName = ".\(fileURL.deletingPathExtension().lastPathComponent)_SUPPORT"
|
||||||
|
let temporaryExternalStorageURL = temporaryDirectoryURL.appendingPathComponent(
|
||||||
|
externalStorageFolderName,
|
||||||
|
isDirectory: true
|
||||||
|
)
|
||||||
let temporaryFileURL = temporaryDirectoryURL.appendingPathComponent(
|
let temporaryFileURL = temporaryDirectoryURL.appendingPathComponent(
|
||||||
fileURL.lastPathComponent,
|
fileURL.lastPathComponent,
|
||||||
isDirectory: false
|
isDirectory: false
|
||||||
@@ -796,25 +801,22 @@ public extension DataStack {
|
|||||||
throw CoreStoreError(error)
|
throw CoreStoreError(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
let externalStorageDirName = "." + fileURL.deletingPathExtension().lastPathComponent + "_SUPPORT"
|
|
||||||
let temporaryExternalStorageURL = temporaryDirectoryURL.appendingPathComponent(
|
|
||||||
externalStorageDirName,
|
|
||||||
isDirectory: true
|
|
||||||
)
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
try fileManager.replaceItem(
|
try fileManager.replaceItem(
|
||||||
at: fileURL as URL,
|
at: fileURL,
|
||||||
withItemAt: temporaryFileURL,
|
withItemAt: temporaryFileURL,
|
||||||
backupItemName: nil,
|
backupItemName: nil,
|
||||||
options: [],
|
options: [],
|
||||||
resultingItemURL: nil
|
resultingItemURL: nil
|
||||||
)
|
)
|
||||||
|
|
||||||
if fileManager.fileExists(atPath: temporaryExternalStorageURL.path) {
|
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(
|
try fileManager.replaceItem(
|
||||||
at: extenralStorageURL as URL,
|
at: externalStorageURL,
|
||||||
withItemAt: temporaryExternalStorageURL,
|
withItemAt: temporaryExternalStorageURL,
|
||||||
backupItemName: nil,
|
backupItemName: nil,
|
||||||
options: [],
|
options: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user