Removes temporary database backup on launch
This commit is contained in:
parent
cec169c9b2
commit
962d45e4f9
@ -62,29 +62,17 @@ extension DatabaseManager
|
|||||||
{
|
{
|
||||||
guard !self.isStarted else { return }
|
guard !self.isStarted else { return }
|
||||||
|
|
||||||
do
|
self.loadPersistentStores { (description, error) in
|
||||||
{
|
guard error == nil else { return completionHandler(error) }
|
||||||
if !FileManager.default.fileExists(atPath: DatabaseManager.backupDirectoryURL.path)
|
|
||||||
{
|
|
||||||
try FileManager.default.copyItem(at: DatabaseManager.defaultDirectoryURL(), to: DatabaseManager.backupDirectoryURL)
|
|
||||||
}
|
|
||||||
|
|
||||||
self.loadPersistentStores { (description, error) in
|
self.prepareDatabase {
|
||||||
guard error == nil else { return completionHandler(error) }
|
self.isStarted = true
|
||||||
|
|
||||||
self.prepareDatabase {
|
NotificationCenter.default.post(name: DatabaseManager.didStartNotification, object: self)
|
||||||
self.isStarted = true
|
|
||||||
|
completionHandler(nil)
|
||||||
NotificationCenter.default.post(name: DatabaseManager.didStartNotification, object: self)
|
|
||||||
|
|
||||||
completionHandler(nil)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
{
|
|
||||||
completionHandler(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,12 +490,6 @@ 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