From 409a5046e3ace4b5c4cd5c307302480b85093911 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Sun, 18 Feb 2024 10:51:42 +0100 Subject: [PATCH] Clean up FileHandler --- lib/handlers/file_handler.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/handlers/file_handler.dart b/lib/handlers/file_handler.dart index 068f504..4e8733b 100644 --- a/lib/handlers/file_handler.dart +++ b/lib/handlers/file_handler.dart @@ -55,7 +55,7 @@ class FileHandler extends ReportHandler { Future _processReport(Report report) async { if (_fileValidationResult) { - await _openFile(report); + await _openFile(); await _writeReportToFile(report); await _closeFile(); return true; @@ -83,7 +83,11 @@ class FileHandler extends ReportHandler { } } - Future _openFile(Report report) async { + Future _openFile() async { + if (_openedFile == null) { + _printLog('Could not open file'); + return; + } _sink = _openedFile!.openWrite(mode: FileMode.append); _printLog('Opened file'); }