Skip to content

Commit

Permalink
fixed background db init
Browse files Browse the repository at this point in the history
  • Loading branch information
clragon committed Nov 12, 2024
1 parent 1595462 commit db4eb09
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/app/data/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ void executeBackgroundTasks() => Workmanager().executeTask(
final logger = Logger('BackgroundTasks');
logger.info('Executing Task $task');

AppStorage storage = await initializeAppStorage(cache: false);
AppStorage? storage;

try {
storage = await initializeAppStorage(cache: false);

final cancelToken = createBackgroundCancelToken(task);
cancelToken.whenCancel.then((e) {
logger.info('Task $task was cancelled: ${e.error}');
Expand All @@ -43,7 +45,7 @@ void executeBackgroundTasks() => Workmanager().executeTask(
logger.severe('Failed executing Task $task', e, stack);
rethrow;
} finally {
await storage.close();
await storage?.close();
logger.info('Task $task completed');
}
},
Expand Down

0 comments on commit db4eb09

Please sign in to comment.