Index: sdk/lib/io/file_impl.dart |
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart |
index ee71e567597cede20a3dddcf8fbbacf24bfd7916..dd618b3a7dbf904795b3626a661652f76163cb3a 100644 |
--- a/sdk/lib/io/file_impl.dart |
+++ b/sdk/lib/io/file_impl.dart |
@@ -90,7 +90,7 @@ class _FileStream extends Stream<List<int>> { |
_readInProgress = false; |
if (!_unsubscribed) { |
_controller.addError(new RangeError("Bad end position: $_end")); |
- _closeFile().then((_) { _controller.close(); }); |
+ _closeFile(); |
_unsubscribed = true; |
} |
return; |
@@ -143,6 +143,7 @@ class _FileStream extends Stream<List<int>> { |
} else { |
openFuture = new Future.value(_File._openStdioSync(0)); |
} |
+ _readInProgress = true; |
openFuture |
.then((RandomAccessFile opened) { |
_openedFile = opened; |
@@ -150,10 +151,13 @@ class _FileStream extends Stream<List<int>> { |
return opened.setPosition(_position); |
} |
}) |
+ .whenComplete(() { |
+ _readInProgress = false; |
+ }) |
.then((_) => _readBlock()) |
.catchError((e) { |
_controller.addError(e); |
- _controller.close(); |
+ _closeFile(); |
}); |
} |