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;
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<String> _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]);
......
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