Skip to content

Commit 58d97d6

Browse files
committed
AdvancedFileOutput: Fix race condition while flushing the buffer, fixes #99
1 parent 9006f29 commit 58d97d6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/src/outputs/advanced_file_output.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,15 @@ class AdvancedFileOutput extends LogOutput {
217217
}
218218

219219
Future<void> _closeSink() async {
220+
final sink = _sink;
221+
_sink = null; // disable writing in flushBuffer
222+
220223
if (fileFooter != null) {
221224
_sink?.writeln(fileFooter);
222225
}
223226

224-
await _sink?.flush();
225-
await _sink?.close();
226-
_sink = null; // Explicitly set null until assigned again
227+
await sink?.flush();
228+
await sink?.close();
227229
}
228230

229231
Future<void> _deleteRotatedFiles() async {

0 commit comments

Comments
 (0)