mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-11-27 19:02:37 +01:00
Migrate external storage
This commit is contained in:
1 parent
4b9fddad6a
commit
51961dd737
1 file changed
+17
@@ -796,6 +796,11 @@ public extension DataStack {
|
|||||||
throw CoreStoreError(error)
|
throw CoreStoreError(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let externalStorageDirName = "." + fileURL.deletingPathExtension().lastPathComponent + "_SUPPORT"
|
||||||
|
let temporaryExtenralStorageURL = temporaryDirectoryURL.appendingPathComponent(
|
||||||
|
externalStorageDirName,
|
||||||
|
isDirectory: true
|
||||||
|
)
|
||||||
do {
|
do {
|
||||||
|
|
||||||
try fileManager.replaceItem(
|
try fileManager.replaceItem(
|
||||||
@@ -806,11 +811,23 @@ public extension DataStack {
|
|||||||
resultingItemURL: nil
|
resultingItemURL: nil
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if fileManager.fileExists(atPath: temporaryExtenralStorageURL.path) {
|
||||||
|
let extenralStorageURL = fileURL.deletingLastPathComponent().appendingPathComponent(externalStorageDirName, isDirectory: true)
|
||||||
|
try fileManager.replaceItem(
|
||||||
|
at: extenralStorageURL as URL,
|
||||||
|
withItemAt: temporaryExtenralStorageURL,
|
||||||
|
backupItemName: nil,
|
||||||
|
options: [],
|
||||||
|
resultingItemURL: nil
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
progress.completedUnitCount = progress.totalUnitCount
|
progress.completedUnitCount = progress.totalUnitCount
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
|
||||||
_ = try? fileManager.removeItem(at: temporaryFileURL)
|
_ = try? fileManager.removeItem(at: temporaryFileURL)
|
||||||
|
_ = try? fileManager.removeItem(at: temporaryExtenralStorageURL)
|
||||||
throw CoreStoreError(error)
|
throw CoreStoreError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user