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) {
for (FileSystemEntity dir in directory.listSync()) {
if (dir is Directory) {
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 {
components.keystore = new File(artifactPaths[3]);
if (!components.androidSdk.existsSync()) {
_logging.severe('Can not locate Android SDK: ${androidSdkPath}');
_logging.severe('Can not locate Android SDK: $androidSdkPath');
return null;
}
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('and version $_kBuildToolsVersion of the build tools.');
return null;
......
......@@ -98,8 +98,8 @@ class UpdateTask {
_tempPath = path.join(_dataDir, 'tmp.skyx');
String bundleUrl = _currentManifest['update-url'] + '/' + kBundleFile;
UrlResponse response = await fetchUrl(bundleUrl);
MojoResult result = await PipeToFile.copyToFile(response.body, _tempPath);
if (!result.isOk)
int result = await PipeToFile.copyToFile(response.body, _tempPath);
if (result != MojoResult.kOk)
throw new UpdateFailure('Failure fetching new package: ${response.statusLine}');
}
......
......@@ -11,15 +11,15 @@ import 'package:mojo/core.dart';
// Helper class to drain the contents of a mojo data pipe to a file.
class PipeToFile {
MojoDataPipeConsumer _consumer;
MojoEventSubscription _eventStream;
MojoEventSubscription _events;
IOSink _outputStream;
PipeToFile(this._consumer, String outputPath) {
_eventStream = new MojoEventSubscription(_consumer.handle);
_events = new MojoEventSubscription(_consumer.handle);
_outputStream = new File(outputPath).openWrite();
}
Future<MojoResult> _doRead() async {
Future<int> _doRead() async {
ByteData thisRead = _consumer.beginRead();
if (thisRead == null) {
throw 'Data pipe beginRead failed: ${_consumer.status}';
......@@ -30,34 +30,34 @@ class PipeToFile {
return _consumer.endRead(thisRead.lengthInBytes);
}
Future drain() async {
Completer completer = new Completer();
// TODO(mpcomplete): Is it legit to pass an async callback to listen?
_eventStream.subscribe((List<int> event) async {
MojoHandleSignals mojoSignals = new MojoHandleSignals(event[1]);
if (mojoSignals.isReadable) {
MojoResult result = await _doRead();
if (!result.isOk) {
_eventStream.close();
_eventStream = null;
Future<int> drain() {
Completer<int> completer = new Completer();
// TODO(mpcomplete): Is it legit to pass an async callback to subscribe?
_events.subscribe((List<int> event) async {
int signal = event[1];
if (MojoHandleSignals.isReadable(signal)) {
int result = await _doRead();
if (result != MojoResult.kOk) {
_events.close();
_events = null;
_outputStream.close();
completer.complete(result);
} else {
_eventStream.enableReadEvents();
_events.enableReadEvents();
}
} else if (mojoSignals.isPeerClosed) {
_eventStream.close();
_eventStream = null;
} else if (MojoHandleSignals.isPeerClosed(signal)) {
_events.close();
_events = null;
_outputStream.close();
completer.complete(MojoResult.OK);
completer.complete(MojoResult.kOk);
} else {
throw 'Unexpected handle event: $mojoSignals';
throw 'Unexpected handle event: ${MojoHandleSignals.string(signal)}';
}
});
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);
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