Commit a320e712 authored by James Robinson's avatar James Robinson

Address review feedback from pull request #30

parent 7f8319fd
...@@ -7,6 +7,10 @@ library sky_tools.artifacts; ...@@ -7,6 +7,10 @@ library sky_tools.artifacts;
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:logging/logging.dart';
final Logger _logging = new Logger('sky_tools.device');
enum Artifact { enum Artifact {
FlutterCompiler, FlutterCompiler,
} }
...@@ -15,13 +19,16 @@ class _ArtifactStore { ...@@ -15,13 +19,16 @@ class _ArtifactStore {
_ArtifactStore._(); _ArtifactStore._();
Future _downloadFile(String url, File file) async { Future _downloadFile(String url, File file) async {
HttpClient httpClient = new HttpClient(); _logging.fine('Downloading $url to ${file.path}');
HttpClientRequest request = await httpClient.getUrl(Uri.parse(url)); HttpClient httpClient = new HttpClient();
HttpClientResponse response = await request.close(); HttpClientRequest request = await httpClient.getUrl(Uri.parse(url));
if (response.statusCode != 200) throw new Exception(response.reasonPhrase); HttpClientResponse response = await request.close();
IOSink sink = file.openWrite(); _logging.fine('Received response');
await sink.addStream(response); if (response.statusCode != 200) throw new Exception(response.reasonPhrase);
await sink.close(); IOSink sink = file.openWrite();
await sink.addStream(response);
await sink.close();
_logging.fine('Wrote file');
} }
Future<String> _getEngineRevision(String packageRoot) { Future<String> _getEngineRevision(String packageRoot) {
...@@ -44,7 +51,7 @@ class _ArtifactStore { ...@@ -44,7 +51,7 @@ class _ArtifactStore {
if (artifact == Artifact.FlutterCompiler) { if (artifact == Artifact.FlutterCompiler) {
File skySnapshotFile = new File(cacheDir.path + 'sky_snapshot'); File skySnapshotFile = new File(cacheDir.path + 'sky_snapshot');
if (!await skySnapshotFile.exists()) { 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'; String googleStorageUrl = 'https://storage.googleapis.com/mojo/sky/shell/linux-x64/${engineRevision}/sky_snapshot';
await _downloadFile(googleStorageUrl, skySnapshotFile); await _downloadFile(googleStorageUrl, skySnapshotFile);
ProcessResult result = await Process.run('chmod', ['u+x', skySnapshotFile.path]); ProcessResult result = await Process.run('chmod', ['u+x', skySnapshotFile.path]);
......
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