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