From a320e712deffe29bea478509f783f25bbb31facc Mon Sep 17 00:00:00 2001 From: James Robinson Date: Fri, 18 Sep 2015 17:03:14 -0700 Subject: [PATCH] Address review feedback from pull request #30 --- packages/flutter_tools/lib/src/artifacts.dart | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart index 6b91f47c18..f67bf57e5f 100644 --- a/packages/flutter_tools/lib/src/artifacts.dart +++ b/packages/flutter_tools/lib/src/artifacts.dart @@ -7,6 +7,10 @@ library sky_tools.artifacts; import 'dart:async'; import 'dart:io'; +import 'package:logging/logging.dart'; + +final Logger _logging = new Logger('sky_tools.device'); + enum Artifact { FlutterCompiler, } @@ -15,13 +19,16 @@ class _ArtifactStore { _ArtifactStore._(); Future _downloadFile(String url, File file) async { - HttpClient httpClient = new HttpClient(); - HttpClientRequest request = await httpClient.getUrl(Uri.parse(url)); - HttpClientResponse response = await request.close(); - if (response.statusCode != 200) throw new Exception(response.reasonPhrase); - IOSink sink = file.openWrite(); - await sink.addStream(response); - await sink.close(); + _logging.fine('Downloading $url to ${file.path}'); + HttpClient httpClient = new HttpClient(); + HttpClientRequest request = await httpClient.getUrl(Uri.parse(url)); + HttpClientResponse response = await request.close(); + _logging.fine('Received response'); + if (response.statusCode != 200) throw new Exception(response.reasonPhrase); + IOSink sink = file.openWrite(); + await sink.addStream(response); + await sink.close(); + _logging.fine('Wrote file'); } Future _getEngineRevision(String packageRoot) { @@ -44,7 +51,7 @@ class _ArtifactStore { if (artifact == Artifact.FlutterCompiler) { File skySnapshotFile = new File(cacheDir.path + 'sky_snapshot'); if (!await skySnapshotFile.exists()) { - print('Downloading sky_snapshot from the cloud, one moment please...'); + _logging.info('Downloading sky_snapshot from the cloud, one moment please...'); String googleStorageUrl = 'https://storage.googleapis.com/mojo/sky/shell/linux-x64/${engineRevision}/sky_snapshot'; await _downloadFile(googleStorageUrl, skySnapshotFile); ProcessResult result = await Process.run('chmod', ['u+x', skySnapshotFile.path]);