From ab998239a41e2614b7401d9bd00a4d7c5042dcf5 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 20 Jul 2021 08:35:52 -0700 Subject: [PATCH] Extract the prebuilt Dart SDK to a temp directory and then move it after the extraction completes (flutter/engine#27569) * Extract the prebuilt Dart SDK to a temp directory and then move it after the extraction completes This ensures that the GN script will not see an invalid Dart SDK at the expected path if the extract fails. * Add os_arch to temp extraction path Co-authored-by: Zachary Anderson --- engine/src/flutter/tools/download_dart_sdk.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/tools/download_dart_sdk.py b/engine/src/flutter/tools/download_dart_sdk.py index e46ca41790c..dd1dd2c09fa 100755 --- a/engine/src/flutter/tools/download_dart_sdk.py +++ b/engine/src/flutter/tools/download_dart_sdk.py @@ -150,7 +150,9 @@ def ExtractDartSDK(archive, os_name, arch, verbose): if os.path.isdir(dart_sdk): shutil.rmtree(dart_sdk) - extract_dest = os.path.join(FLUTTER_PREBUILTS_DIR, os_arch) + extract_dest = os.path.join(FLUTTER_PREBUILTS_DIR, os_arch, 'temp') + if os.path.isdir(extract_dest): + shutil.rmtree(extract_dest) os.makedirs(extract_dest, exist_ok=True) if verbose: @@ -159,6 +161,8 @@ def ExtractDartSDK(archive, os_name, arch, verbose): with ZipFileWithPermissions(archive, "r") as z: z.extractall(extract_dest) + shutil.move(os.path.join(extract_dest, 'dart-sdk'), dart_sdk) + def PrintFileIfSmall(file): if not os.path.isfile(file):