Backs up Database folder on first launch
Allows beta testers to recover data while testing Harmony syncing if something goes wrong
This commit is contained in:
parent
4bbfee5e8f
commit
708ebb1a7f
@ -85,6 +85,13 @@ extension DatabaseManager
|
|||||||
{
|
{
|
||||||
guard !self.isStarted else { return }
|
guard !self.isStarted else { return }
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if !FileManager.default.fileExists(atPath: DatabaseManager.backupDirectoryURL.path)
|
||||||
|
{
|
||||||
|
try FileManager.default.copyItem(at: DatabaseManager.defaultDirectoryURL(), to: DatabaseManager.backupDirectoryURL)
|
||||||
|
}
|
||||||
|
|
||||||
self.loadPersistentStores { (description, error) in
|
self.loadPersistentStores { (description, error) in
|
||||||
guard error == nil else { return completionHandler(error) }
|
guard error == nil else { return completionHandler(error) }
|
||||||
|
|
||||||
@ -94,6 +101,11 @@ extension DatabaseManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
completionHandler(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: - Update -
|
//MARK: - Update -
|
||||||
@ -505,6 +517,12 @@ extension DatabaseManager
|
|||||||
let artworkURL = gameURL.deletingPathExtension().appendingPathExtension("jpg")
|
let artworkURL = gameURL.deletingPathExtension().appendingPathExtension("jpg")
|
||||||
return artworkURL
|
return artworkURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class var backupDirectoryURL: URL
|
||||||
|
{
|
||||||
|
let backupDirectoryURL = FileManager.default.documentsDirectory.appendingPathComponent("Database-Backup")
|
||||||
|
return backupDirectoryURL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: - Notifications -
|
//MARK: - Notifications -
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user