Migrate documents to App Group
This commit is contained in:
parent
8ede1ed3d4
commit
87249cb8ad
|
@ -51,6 +51,7 @@ class TransientStore {
|
|||
}
|
||||
|
||||
private init() {
|
||||
TransientStore.migrateDocumentsToAppGroup()
|
||||
|
||||
// this must be graceful
|
||||
ConnectionService.migrateJSON(from: TransientStore.serviceURL, to: TransientStore.serviceURL)
|
||||
|
@ -85,4 +86,26 @@ class TransientStore {
|
|||
service.saveProfiles()
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
private static func migrateDocumentsToAppGroup() {
|
||||
let oldDocumentsURL = FileManager.default.userURL(for: .documentDirectory, appending: nil)
|
||||
let newDocumentsURL = GroupConstants.App.documentsURL
|
||||
log.debug("App documentsURL: \(oldDocumentsURL)")
|
||||
log.debug("Group documentsURL: \(newDocumentsURL)")
|
||||
let fm = FileManager.default
|
||||
do {
|
||||
for c in try fm.contentsOfDirectory(atPath: oldDocumentsURL.path) {
|
||||
let old = oldDocumentsURL.appendingPathComponent(c)
|
||||
let new = newDocumentsURL.appendingPathComponent(c)
|
||||
log.verbose("Move:")
|
||||
log.verbose("\tFROM: \(old)")
|
||||
log.verbose("\tTO: \(new)")
|
||||
try fm.moveItem(at: old, to: new)
|
||||
}
|
||||
} catch let e {
|
||||
log.error("Could not migrate documents to App Group: \(e)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue