Commit 630284bd authored by Adam Barth's avatar Adam Barth

Merge pull request #544 from abarth/fix_analyzer

Fix analyzer warnings
parents cbc79c57 99d51f5f
...@@ -10,7 +10,12 @@ update(Directory directory) { ...@@ -10,7 +10,12 @@ update(Directory directory) {
for (FileSystemEntity dir in directory.listSync()) { for (FileSystemEntity dir in directory.listSync()) {
if (dir is Directory) { if (dir is Directory) {
print("Updating ${dir.path}..."); print("Updating ${dir.path}...");
Process.runSync(binaryName, ['get'], workingDirectory: dir.path); ProcessResult result = Process.runSync(binaryName, ['get'], workingDirectory: dir.path);
if (result.exitCode != 0) {
print("... failed with exit code ${result.exitCode}.");
print(result.stdout);
print(result.stderr);
}
} }
} }
} }
......
...@@ -172,11 +172,11 @@ class ApkCommand extends FlutterCommand { ...@@ -172,11 +172,11 @@ class ApkCommand extends FlutterCommand {
components.keystore = new File(artifactPaths[3]); components.keystore = new File(artifactPaths[3]);
if (!components.androidSdk.existsSync()) { if (!components.androidSdk.existsSync()) {
_logging.severe('Can not locate Android SDK: ${androidSdkPath}'); _logging.severe('Can not locate Android SDK: $androidSdkPath');
return null; return null;
} }
if (!(new _ApkBuilder(components.androidSdk.path).checkSdkPath())) { if (!(new _ApkBuilder(components.androidSdk.path).checkSdkPath())) {
_logging.severe('Can not locate expected Android SDK tools at ${androidSdkPath}'); _logging.severe('Can not locate expected Android SDK tools at $androidSdkPath');
_logging.severe('You must install version $_kAndroidPlatformVersion of the SDK platform'); _logging.severe('You must install version $_kAndroidPlatformVersion of the SDK platform');
_logging.severe('and version $_kBuildToolsVersion of the build tools.'); _logging.severe('and version $_kBuildToolsVersion of the build tools.');
return null; return null;
......
...@@ -98,8 +98,8 @@ class UpdateTask { ...@@ -98,8 +98,8 @@ class UpdateTask {
_tempPath = path.join(_dataDir, 'tmp.skyx'); _tempPath = path.join(_dataDir, 'tmp.skyx');
String bundleUrl = _currentManifest['update-url'] + '/' + kBundleFile; String bundleUrl = _currentManifest['update-url'] + '/' + kBundleFile;
UrlResponse response = await fetchUrl(bundleUrl); UrlResponse response = await fetchUrl(bundleUrl);
MojoResult result = await PipeToFile.copyToFile(response.body, _tempPath); int result = await PipeToFile.copyToFile(response.body, _tempPath);
if (!result.isOk) if (result != MojoResult.kOk)
throw new UpdateFailure('Failure fetching new package: ${response.statusLine}'); throw new UpdateFailure('Failure fetching new package: ${response.statusLine}');
} }
......
...@@ -11,15 +11,15 @@ import 'package:mojo/core.dart'; ...@@ -11,15 +11,15 @@ import 'package:mojo/core.dart';
// Helper class to drain the contents of a mojo data pipe to a file. // Helper class to drain the contents of a mojo data pipe to a file.
class PipeToFile { class PipeToFile {
MojoDataPipeConsumer _consumer; MojoDataPipeConsumer _consumer;
MojoEventSubscription _eventStream; MojoEventSubscription _events;
IOSink _outputStream; IOSink _outputStream;
PipeToFile(this._consumer, String outputPath) { PipeToFile(this._consumer, String outputPath) {
_eventStream = new MojoEventSubscription(_consumer.handle); _events = new MojoEventSubscription(_consumer.handle);
_outputStream = new File(outputPath).openWrite(); _outputStream = new File(outputPath).openWrite();
} }
Future<MojoResult> _doRead() async { Future<int> _doRead() async {
ByteData thisRead = _consumer.beginRead(); ByteData thisRead = _consumer.beginRead();
if (thisRead == null) { if (thisRead == null) {
throw 'Data pipe beginRead failed: ${_consumer.status}'; throw 'Data pipe beginRead failed: ${_consumer.status}';
...@@ -30,34 +30,34 @@ class PipeToFile { ...@@ -30,34 +30,34 @@ class PipeToFile {
return _consumer.endRead(thisRead.lengthInBytes); return _consumer.endRead(thisRead.lengthInBytes);
} }
Future drain() async { Future<int> drain() {
Completer completer = new Completer(); Completer<int> completer = new Completer();
// TODO(mpcomplete): Is it legit to pass an async callback to listen? // TODO(mpcomplete): Is it legit to pass an async callback to subscribe?
_eventStream.subscribe((List<int> event) async { _events.subscribe((List<int> event) async {
MojoHandleSignals mojoSignals = new MojoHandleSignals(event[1]); int signal = event[1];
if (mojoSignals.isReadable) { if (MojoHandleSignals.isReadable(signal)) {
MojoResult result = await _doRead(); int result = await _doRead();
if (!result.isOk) { if (result != MojoResult.kOk) {
_eventStream.close(); _events.close();
_eventStream = null; _events = null;
_outputStream.close(); _outputStream.close();
completer.complete(result); completer.complete(result);
} else { } else {
_eventStream.enableReadEvents(); _events.enableReadEvents();
} }
} else if (mojoSignals.isPeerClosed) { } else if (MojoHandleSignals.isPeerClosed(signal)) {
_eventStream.close(); _events.close();
_eventStream = null; _events = null;
_outputStream.close(); _outputStream.close();
completer.complete(MojoResult.OK); completer.complete(MojoResult.kOk);
} else { } else {
throw 'Unexpected handle event: $mojoSignals'; throw 'Unexpected handle event: ${MojoHandleSignals.string(signal)}';
} }
}); });
return completer.future; return completer.future;
} }
static Future<MojoResult> copyToFile(MojoDataPipeConsumer consumer, String outputPath) { static Future<int> copyToFile(MojoDataPipeConsumer consumer, String outputPath) {
PipeToFile drainer = new PipeToFile(consumer, outputPath); PipeToFile drainer = new PipeToFile(consumer, outputPath);
return drainer.drain(); return drainer.drain();
} }
......
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