Skip to content

Commit

Permalink
Lazily download artifacts (#27374)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams committed Feb 8, 2019
1 parent 523c5de commit 98971f3
Show file tree
Hide file tree
Showing 16 changed files with 944 additions and 219 deletions.
3 changes: 3 additions & 0 deletions packages/flutter_tools/bin/fuchsia_attach.dart
Expand Up @@ -134,4 +134,7 @@ class _FuchsiaAttachCommand extends AttachCommand {
Cache.flutterRoot = '$originalWorkingDirectory/third_party/dart-pkg/git/flutter';
return super.runCommand();
}

@override
Future<void> updateCache() async {}
}
6 changes: 5 additions & 1 deletion packages/flutter_tools/bin/xcode_backend.sh
Expand Up @@ -84,7 +84,6 @@ BuildApp() {

local framework_path="${FLUTTER_ROOT}/bin/cache/artifacts/engine/${artifact_variant}"

AssertExists "${framework_path}"
AssertExists "${project_path}"

local derived_dir="${SOURCE_ROOT}/Flutter"
Expand Down Expand Up @@ -118,6 +117,11 @@ BuildApp() {
flutter_podspec="${LOCAL_ENGINE}/Flutter.podspec"
fi

# If the framework path does not exist, ensure that it is downloaded.
if [[ ! -e "$1" ]]; then
RunCommand "${FLUTTER_ROOT}/bin/flutter" precache --suppress-analytics
fi

if [[ -e "${project_path}/.ios" ]]; then
RunCommand rm -rf -- "${derived_dir}/engine"
mkdir "${derived_dir}/engine"
Expand Down
7 changes: 4 additions & 3 deletions packages/flutter_tools/lib/src/base/net.dart
Expand Up @@ -37,7 +37,8 @@ Future<List<int>> _attempt(Uri url, {bool onlyHeaders = false}) async {
printTrace('Downloading: $url');
HttpClient httpClient;
if (context[HttpClientFactory] != null) {
httpClient = (context[HttpClientFactory] as HttpClientFactory)(); // ignore: avoid_as
final HttpClientFactory httpClientFactory = context[HttpClientFactory];
httpClient = httpClientFactory();
} else {
httpClient = HttpClient();
}
Expand All @@ -64,9 +65,9 @@ Future<List<int>> _attempt(Uri url, {bool onlyHeaders = false}) async {
// If we're making a HEAD request, we're only checking to see if the URL is
// valid.
if (onlyHeaders) {
return (response.statusCode == 200) ? <int>[] : null;
return (response.statusCode == HttpStatus.ok) ? <int>[] : null;
}
if (response.statusCode != 200) {
if (response.statusCode != HttpStatus.ok) {
if (response.statusCode > 0 && response.statusCode < 500) {
throwToolExit(
'Download failed.\n'
Expand Down

0 comments on commit 98971f3

Please sign in to comment.