Unverified Commit 57cd3252 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

When updating packages, do not delete the simulated SDK directory until all...

When updating packages, do not delete the simulated SDK directory until all pub invocations have finished (#112975)
parent 559d524e
...@@ -377,6 +377,7 @@ class UpdatePackagesCommand extends FlutterCommand { ...@@ -377,6 +377,7 @@ class UpdatePackagesCommand extends FlutterCommand {
required PubDependencyTree tree, required PubDependencyTree tree,
required bool doUpgrade, required bool doUpgrade,
}) async { }) async {
Directory? temporaryFlutterSdk;
try { try {
final File fakePackage = _pubspecFor(tempDir); final File fakePackage = _pubspecFor(tempDir);
fakePackage.createSync(); fakePackage.createSync();
...@@ -388,7 +389,6 @@ class UpdatePackagesCommand extends FlutterCommand { ...@@ -388,7 +389,6 @@ class UpdatePackagesCommand extends FlutterCommand {
); );
// Create a synthetic flutter SDK so that transitive flutter SDK // Create a synthetic flutter SDK so that transitive flutter SDK
// constraints are not affected by this upgrade. // constraints are not affected by this upgrade.
Directory? temporaryFlutterSdk;
if (doUpgrade) { if (doUpgrade) {
temporaryFlutterSdk = createTemporaryFlutterSdk( temporaryFlutterSdk = createTemporaryFlutterSdk(
globals.logger, globals.logger,
...@@ -407,12 +407,6 @@ class UpdatePackagesCommand extends FlutterCommand { ...@@ -407,12 +407,6 @@ class UpdatePackagesCommand extends FlutterCommand {
offline: boolArgDeprecated('offline'), offline: boolArgDeprecated('offline'),
flutterRootOverride: temporaryFlutterSdk?.path, flutterRootOverride: temporaryFlutterSdk?.path,
); );
// Cleanup the temporary SDK
try {
temporaryFlutterSdk?.deleteSync(recursive: true);
} on FileSystemException {
// Failed to delete temporary SDK.
}
if (doUpgrade) { if (doUpgrade) {
// If upgrading, we run "pub deps --style=compact" on the result. We // If upgrading, we run "pub deps --style=compact" on the result. We
...@@ -428,6 +422,12 @@ class UpdatePackagesCommand extends FlutterCommand { ...@@ -428,6 +422,12 @@ class UpdatePackagesCommand extends FlutterCommand {
); );
} }
} finally { } finally {
// Cleanup the temporary SDK
try {
temporaryFlutterSdk?.deleteSync(recursive: true);
} on FileSystemException {
// Failed to delete temporary SDK.
}
tempDir.deleteSync(recursive: true); tempDir.deleteSync(recursive: true);
} }
} }
......
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