@@ -147,7 +147,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
147
147
/// Apple's documentation on the matter)
148
148
UNUserNotificationCenter . current ( ) . delegate = self
149
149
150
- Storage . resumeDatabaseAccess ( )
150
+ Storage . resumeDatabaseAccess ( using : dependencies )
151
151
LibSession . resumeNetworkAccess ( )
152
152
153
153
// Reset the 'startTime' (since it would be invalid from the last launch)
@@ -209,10 +209,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
209
209
stopPollers ( shouldStopUserPoller: !self . hasCallOngoing ( ) )
210
210
211
211
// 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
213
213
if !self . hasCallOngoing ( ) && ( !neededBackgroundProcessing || Singleton . hasAppContext && Singleton . appContext. isInBackground) {
214
214
LibSession . suspendNetworkAccess ( )
215
- Storage . suspendDatabaseAccess ( )
215
+ Storage . suspendDatabaseAccess ( using : dependencies )
216
216
Log . info ( " [AppDelegate] completed network and database shutdowns. " )
217
217
Log . flush ( )
218
218
}
@@ -238,7 +238,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
238
238
UserDefaults . sharedLokiProject ? [ . isMainAppActive] = true
239
239
240
240
// 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 )
242
242
LibSession . resumeNetworkAccess ( )
243
243
244
244
ensureRootViewController ( calledFrom: . didBecomeActive)
@@ -288,7 +288,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
288
288
func application( _ application: UIApplication , performFetchWithCompletionHandler completionHandler: @escaping ( UIBackgroundFetchResult ) -> Void ) {
289
289
Log . appResumedExecution ( )
290
290
Log . info ( " Starting background fetch. " )
291
- Storage . resumeDatabaseAccess ( )
291
+ Storage . resumeDatabaseAccess ( using : dependencies )
292
292
LibSession . resumeNetworkAccess ( )
293
293
294
294
let queue : DispatchQueue = . global( qos: . userInitiated)
@@ -302,7 +302,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
302
302
let cancelTimer : Timer = Timer . scheduledTimerOnMainThread (
303
303
withTimeInterval: ( application. backgroundTimeRemaining - 5 ) ,
304
304
repeats: false
305
- ) { [ poller] timer in
305
+ ) { [ poller, dependencies ] timer in
306
306
timer. invalidate ( )
307
307
308
308
guard cancellable != nil else { return }
@@ -312,7 +312,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
312
312
313
313
if Singleton . hasAppContext && Singleton . appContext. isInBackground {
314
314
LibSession . suspendNetworkAccess ( )
315
- Storage . suspendDatabaseAccess ( )
315
+ Storage . suspendDatabaseAccess ( using : dependencies )
316
316
Log . flush ( )
317
317
}
318
318
@@ -338,7 +338,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
338
338
339
339
if Singleton . hasAppContext && Singleton . appContext. isInBackground {
340
340
LibSession . suspendNetworkAccess ( )
341
- Storage . suspendDatabaseAccess ( )
341
+ Storage . suspendDatabaseAccess ( using : dependencies )
342
342
Log . flush ( )
343
343
}
344
344
@@ -934,7 +934,7 @@ private enum StartupError: Error {
934
934
935
935
var name : String {
936
936
switch self {
937
- case . databaseError( StorageError . startupFailed) , . databaseError( DatabaseError . SQLITE_LOCKED) :
937
+ case . databaseError( StorageError . startupFailed) , . databaseError( DatabaseError . SQLITE_LOCKED) , . databaseError ( StorageError . databaseSuspended ) :
938
938
return " Database startup failed "
939
939
940
940
case . databaseError( StorageError . migrationNoLongerSupported) : return " Unsupported version "
@@ -946,7 +946,7 @@ private enum StartupError: Error {
946
946
947
947
var message : String {
948
948
switch self {
949
- case . databaseError( StorageError . startupFailed) , . databaseError( DatabaseError . SQLITE_LOCKED) :
949
+ case . databaseError( StorageError . startupFailed) , . databaseError( DatabaseError . SQLITE_LOCKED) , . databaseError ( StorageError . databaseSuspended ) :
950
950
return " DATABASE_STARTUP_FAILED " . localized ( )
951
951
952
952
case . databaseError( StorageError . migrationNoLongerSupported) :
0 commit comments