diff --git a/Tusker/MainSceneDelegate.swift b/Tusker/MainSceneDelegate.swift index f60ebdc5..0dec6de8 100644 --- a/Tusker/MainSceneDelegate.swift +++ b/Tusker/MainSceneDelegate.swift @@ -123,7 +123,10 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate { rootVC.sceneDidEnterBackground() } - if let context = scene.session.mastodonController?.persistentContainer.viewContext { + if let context = scene.session.mastodonController?.persistentContainer.viewContext, + // if the user quickly opens and then closes the app, this may race with loading the persistent store, so in that event we skip cleanup/save + let psc = context.persistentStoreCoordinator, + !psc.persistentStores.isEmpty { var minDate = Date() minDate.addTimeInterval(-7 * 24 * 60 * 60)