@@ -147,7 +147,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
147147 /// Apple's documentation on the matter)
148148 UNUserNotificationCenter . current ( ) . delegate = self
149149
150- Storage . resumeDatabaseAccess ( )
150+ Storage . resumeDatabaseAccess ( using : dependencies )
151151 LibSession . resumeNetworkAccess ( )
152152
153153 // Reset the 'startTime' (since it would be invalid from the last launch)
@@ -209,10 +209,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
209209 stopPollers ( shouldStopUserPoller: !self . hasCallOngoing ( ) )
210210
211211 // Stop all jobs except for message sending and when completed suspend the database
212- JobRunner . stopAndClearPendingJobs ( exceptForVariant: . messageSend, using: dependencies) { neededBackgroundProcessing in
212+ JobRunner . stopAndClearPendingJobs ( exceptForVariant: . messageSend, using: dependencies) { [ dependencies ] neededBackgroundProcessing in
213213 if !self . hasCallOngoing ( ) && ( !neededBackgroundProcessing || Singleton . hasAppContext && Singleton . appContext. isInBackground) {
214214 LibSession . suspendNetworkAccess ( )
215- Storage . suspendDatabaseAccess ( )
215+ Storage . suspendDatabaseAccess ( using : dependencies )
216216 Log . info ( " [AppDelegate] completed network and database shutdowns. " )
217217 Log . flush ( )
218218 }
@@ -238,7 +238,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
238238 UserDefaults . sharedLokiProject ? [ . isMainAppActive] = true
239239
240240 // FIXME: Seems like there are some discrepancies between the expectations of how the iOS lifecycle methods work, we should look into them and ensure the code behaves as expected (in this case there were situations where these two wouldn't get called when returning from the background)
241- Storage . resumeDatabaseAccess ( )
241+ Storage . resumeDatabaseAccess ( using : dependencies )
242242 LibSession . resumeNetworkAccess ( )
243243
244244 ensureRootViewController ( calledFrom: . didBecomeActive)
@@ -288,7 +288,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
288288 func application( _ application: UIApplication , performFetchWithCompletionHandler completionHandler: @escaping ( UIBackgroundFetchResult ) -> Void ) {
289289 Log . appResumedExecution ( )
290290 Log . info ( " Starting background fetch. " )
291- Storage . resumeDatabaseAccess ( )
291+ Storage . resumeDatabaseAccess ( using : dependencies )
292292 LibSession . resumeNetworkAccess ( )
293293
294294 let queue : DispatchQueue = . global( qos: . userInitiated)
@@ -302,7 +302,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
302302 let cancelTimer : Timer = Timer . scheduledTimerOnMainThread (
303303 withTimeInterval: ( application. backgroundTimeRemaining - 5 ) ,
304304 repeats: false
305- ) { [ poller] timer in
305+ ) { [ poller, dependencies ] timer in
306306 timer. invalidate ( )
307307
308308 guard cancellable != nil else { return }
@@ -312,7 +312,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
312312
313313 if Singleton . hasAppContext && Singleton . appContext. isInBackground {
314314 LibSession . suspendNetworkAccess ( )
315- Storage . suspendDatabaseAccess ( )
315+ Storage . suspendDatabaseAccess ( using : dependencies )
316316 Log . flush ( )
317317 }
318318
@@ -338,7 +338,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
338338
339339 if Singleton . hasAppContext && Singleton . appContext. isInBackground {
340340 LibSession . suspendNetworkAccess ( )
341- Storage . suspendDatabaseAccess ( )
341+ Storage . suspendDatabaseAccess ( using : dependencies )
342342 Log . flush ( )
343343 }
344344
@@ -934,7 +934,7 @@ private enum StartupError: Error {
934934
935935 var name : String {
936936 switch self {
937- case . databaseError( StorageError . startupFailed) , . databaseError( DatabaseError . SQLITE_LOCKED) :
937+ case . databaseError( StorageError . startupFailed) , . databaseError( DatabaseError . SQLITE_LOCKED) , . databaseError ( StorageError . databaseSuspended ) :
938938 return " Database startup failed "
939939
940940 case . databaseError( StorageError . migrationNoLongerSupported) : return " Unsupported version "
@@ -946,7 +946,7 @@ private enum StartupError: Error {
946946
947947 var message : String {
948948 switch self {
949- case . databaseError( StorageError . startupFailed) , . databaseError( DatabaseError . SQLITE_LOCKED) :
949+ case . databaseError( StorageError . startupFailed) , . databaseError( DatabaseError . SQLITE_LOCKED) , . databaseError ( StorageError . databaseSuspended ) :
950950 return " DATABASE_STARTUP_FAILED " . localized ( )
951951
952952 case . databaseError( StorageError . migrationNoLongerSupported) :
0 commit comments