Use pool for file reading (#3156)
diff --git a/lib/src/io.dart b/lib/src/io.dart
index 9622eaa..f95408d 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -158,7 +158,9 @@
String readTextFile(String file) => File(file).readAsStringSync();
/// Reads the contents of the text file [file].
-Future<String> readTextFileAsync(String file) => File(file).readAsString();
+Future<String> readTextFileAsync(String file) {
+ return _descriptorPool.withResource(() => File(file).readAsString());
+}
/// Reads the contents of the binary file [file].
List<int> readBinaryFile(String file) {
diff --git a/lib/src/source/hosted.dart b/lib/src/source/hosted.dart
index 11f37b8..72be078 100644
--- a/lib/src/source/hosted.dart
+++ b/lib/src/source/hosted.dart
@@ -352,7 +352,7 @@
PackageRef ref,
{Duration maxAge}) async {
final cachePath = _versionListingCachePath(ref);
- final stat = await io.File(cachePath).stat();
+ final stat = io.File(cachePath).statSync();
final now = DateTime.now();
if (stat.type == io.FileSystemEntityType.file) {
if (maxAge == null || now.difference(stat.modified) < maxAge) {