Unverified Commit ef5fc1ae authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

limit open files on macOS when copying assets (#34050)

parent bc3ca10e
......@@ -5,6 +5,7 @@
import 'dart:async';
import 'package:meta/meta.dart';
import 'package:pool/pool.dart';
import 'artifacts.dart';
import 'asset.dart';
......@@ -226,10 +227,17 @@ Future<void> writeBundle(
bundleDir.deleteSync(recursive: true);
bundleDir.createSync(recursive: true);
// Limit number of open files to avoid running out of file descriptors.
final Pool pool = Pool(64);
await Future.wait<void>(
assetEntries.entries.map<Future<void>>((MapEntry<String, DevFSContent> entry) async {
final File file = fs.file(fs.path.join(bundleDir.path, entry.key));
file.parent.createSync(recursive: true);
await file.writeAsBytes(await entry.value.contentsAsBytes());
final PoolResource resource = await pool.request();
try {
final File file = fs.file(fs.path.join(bundleDir.path, entry.key));
file.parent.createSync(recursive: true);
await file.writeAsBytes(await entry.value.contentsAsBytes());
} finally {
resource.release();
}
}));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment