Chromium Code Reviews| Index: pkg/barback/lib/src/asset.dart |
| diff --git a/pkg/barback/lib/src/asset.dart b/pkg/barback/lib/src/asset.dart |
| index 254edfbdf9577ea0f067f1dbdc9beae6d5d78d8f..fda813380dc1965b6b901db7e043f531256eed41 100644 |
| --- a/pkg/barback/lib/src/asset.dart |
| +++ b/pkg/barback/lib/src/asset.dart |
| @@ -9,6 +9,7 @@ import 'dart:convert'; |
| import 'dart:io'; |
| import 'asset_id.dart'; |
| +import 'file_pool.dart'; |
| import 'stream_replayer.dart'; |
| import 'utils.dart'; |
| @@ -99,16 +100,20 @@ class _BinaryAsset extends Asset { |
| /// An asset backed by a file on the local file system. |
| class _FileAsset extends Asset { |
| + /// Use a [FilePool] to handle reads so we can try to cope with running out |
| + /// of file descriptors more gracefully. |
| + static final _pool = new FilePool(); |
| + |
| final File _file; |
|
nweiz
2013/10/16 00:16:01
I don't understand why we're storing a File object
Bob Nystrom
2013/10/16 00:51:46
FileAsset already has the File object, so this was
|
| _FileAsset(AssetId id, this._file) |
| : super(id); |
| Future<String> readAsString({Encoding encoding}) { |
| if (encoding == null) encoding = UTF8; |
| - return _file.readAsString(encoding: encoding); |
| + return _pool.readAsString(_file, encoding); |
| } |
| - Stream<List<int>> read() => _file.openRead(); |
| + Stream<List<int>> read() => _pool.openRead(_file); |
| String toString() => 'File "${_file.path}"'; |
| } |