Skip to content

Commit cec9791

Browse files
committed
Add back write caching, simplify caching, use sync I/O.
1 parent 33a0a24 commit cec9791

File tree

18 files changed

+532
-708
lines changed

18 files changed

+532
-708
lines changed

_test_common/lib/runner_asset_writer_spy.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,4 @@ class RunnerAssetWriterSpy extends AssetWriterSpy implements RunnerAssetWriter {
2323

2424
@override
2525
Future<void> deleteDirectory(AssetId id) => _delegate.deleteDirectory(id);
26-
27-
@override
28-
Future<void> completeBuild() async {}
2926
}

build/lib/src/state/filesystem.dart

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import 'dart:convert';
66
import 'dart:io';
77
import 'dart:typed_data';
88

9-
import 'package:pool/pool.dart';
10-
119
/// The filesystem the build is running on.
1210
///
1311
/// Methods behave as the `dart:io` methods with the same names, with some
@@ -77,25 +75,21 @@ abstract interface class Filesystem {
7775

7876
/// The `dart:io` filesystem.
7977
class IoFilesystem implements Filesystem {
80-
/// Pool for async file operations.
81-
final _pool = Pool(32);
82-
8378
@override
84-
Future<bool> exists(String path) => _pool.withResource(File(path).exists);
79+
Future<bool> exists(String path) => File(path).exists();
8580

8681
@override
8782
bool existsSync(String path) => File(path).existsSync();
8883

8984
@override
90-
Future<Uint8List> readAsBytes(String path) =>
91-
_pool.withResource(File(path).readAsBytes);
85+
Future<Uint8List> readAsBytes(String path) => File(path).readAsBytes();
9286

9387
@override
9488
Uint8List readAsBytesSync(String path) => File(path).readAsBytesSync();
9589

9690
@override
9791
Future<String> readAsString(String path, {Encoding encoding = utf8}) =>
98-
_pool.withResource(() => File(path).readAsString(encoding: encoding));
92+
File(path).readAsString(encoding: encoding);
9993

10094
@override
10195
String readAsStringSync(String path, {Encoding encoding = utf8}) =>
@@ -108,19 +102,15 @@ class IoFilesystem implements Filesystem {
108102
}
109103

110104
@override
111-
Future<void> delete(String path) {
112-
return _pool.withResource(() async {
113-
final file = File(path);
114-
if (await file.exists()) await file.delete();
115-
});
105+
Future<void> delete(String path) async {
106+
final file = File(path);
107+
if (await file.exists()) await file.delete();
116108
}
117109

118110
@override
119-
Future<void> deleteDirectory(String path) {
120-
return _pool.withResource(() async {
121-
final directory = Directory(path);
122-
if (await directory.exists()) await directory.delete(recursive: true);
123-
});
111+
Future<void> deleteDirectory(String path) async {
112+
final directory = Directory(path);
113+
if (await directory.exists()) await directory.delete(recursive: true);
124114
}
125115

126116
@override
@@ -135,12 +125,10 @@ class IoFilesystem implements Filesystem {
135125
}
136126

137127
@override
138-
Future<void> writeAsBytes(String path, List<int> contents) {
139-
return _pool.withResource(() async {
140-
final file = File(path);
141-
await file.parent.create(recursive: true);
142-
await file.writeAsBytes(contents);
143-
});
128+
Future<void> writeAsBytes(String path, List<int> contents) async {
129+
final file = File(path);
130+
await file.parent.create(recursive: true);
131+
await file.writeAsBytes(contents);
144132
}
145133

146134
@override
@@ -159,12 +147,10 @@ class IoFilesystem implements Filesystem {
159147
String path,
160148
String contents, {
161149
Encoding encoding = utf8,
162-
}) {
163-
return _pool.withResource(() async {
164-
final file = File(path);
165-
await file.parent.create(recursive: true);
166-
await file.writeAsString(contents, encoding: encoding);
167-
});
150+
}) async {
151+
final file = File(path);
152+
await file.parent.create(recursive: true);
153+
await file.writeAsString(contents, encoding: encoding);
168154
}
169155
}
170156

0 commit comments

Comments
 (0)