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

[flutter_tools] prevent NPE due to moved/deleted packages during upgrade packages (#73357)

parent 7c618758
......@@ -1425,12 +1425,13 @@ Directory createTemporaryFlutterSdk(
Directory realFlutter,
List<PubspecYaml> pubspecs,
) {
final Set<String> currentPackages = realFlutter
.childDirectory('packages')
.listSync()
.whereType<Directory>()
.map((Directory directory) => fileSystem.path.basename(directory.path))
.toSet();
final Set<String> currentPackages = <String>{};
for (final FileSystemEntity entity in realFlutter.childDirectory('packages').listSync()) {
// Verify that a pubspec.yaml exists to ensure this isn't a left over directory.
if (entity is Directory && entity.childFile('pubspec.yaml').existsSync()) {
currentPackages.add(fileSystem.path.basename(entity.path));
}
}
final Map<String, PubspecYaml> pubspecsByName = <String, PubspecYaml>{};
for (final PubspecYaml pubspec in pubspecs) {
......
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