mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-15 21:53:39 +01:00
Merge pull request #232 from kf99916/external-storage-migration
External storage migration
This commit is contained in:
@@ -796,6 +796,11 @@ public extension DataStack {
|
||||
throw CoreStoreError(error)
|
||||
}
|
||||
|
||||
let externalStorageDirName = "." + fileURL.deletingPathExtension().lastPathComponent + "_SUPPORT"
|
||||
let temporaryExternalStorageURL = temporaryDirectoryURL.appendingPathComponent(
|
||||
externalStorageDirName,
|
||||
isDirectory: true
|
||||
)
|
||||
do {
|
||||
|
||||
try fileManager.replaceItem(
|
||||
@@ -806,11 +811,23 @@ public extension DataStack {
|
||||
resultingItemURL: nil
|
||||
)
|
||||
|
||||
if fileManager.fileExists(atPath: temporaryExternalStorageURL.path) {
|
||||
let extenralStorageURL = fileURL.deletingLastPathComponent().appendingPathComponent(externalStorageDirName, isDirectory: true)
|
||||
try fileManager.replaceItem(
|
||||
at: extenralStorageURL as URL,
|
||||
withItemAt: temporaryExternalStorageURL,
|
||||
backupItemName: nil,
|
||||
options: [],
|
||||
resultingItemURL: nil
|
||||
)
|
||||
}
|
||||
|
||||
progress.completedUnitCount = progress.totalUnitCount
|
||||
}
|
||||
catch {
|
||||
|
||||
_ = try? fileManager.removeItem(at: temporaryFileURL)
|
||||
_ = try? fileManager.removeItem(at: temporaryExternalStorageURL)
|
||||
throw CoreStoreError(error)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user