Index: tools/gardening/lib/src/client.dart |
diff --git a/tools/gardening/lib/src/client.dart b/tools/gardening/lib/src/client.dart |
index f73a50df5efdeb18501806c07e42d9c9ad58c9f5..850a2f96f3f6b58e1f3af7a9fe84321ac3a99908 100644 |
--- a/tools/gardening/lib/src/client.dart |
+++ b/tools/gardening/lib/src/client.dart |
@@ -28,16 +28,40 @@ class HttpBuildbotClient implements BuildbotClient { |
@override |
Future<BuildResult> readResult(BuildUri buildUri) async { |
- try { |
- return await readBuildResultFromHttp(_client, buildUri); |
- } on HttpException { |
- return null; |
- } on SocketException { |
- return null; |
+ Duration timeout; |
+ if (buildUri.buildNumber < 0) { |
+ timeout = new Duration(seconds: 1); |
+ } |
+ |
+ void skipToPreviousBuildNumber() { |
+ BuildUri prevBuildUri = buildUri.prev(); |
+ log('Skip build number ' |
+ '${buildUri.buildNumber} -> ${prevBuildUri.buildNumber}'); |
+ buildUri = buildUri.prev(); |
+ } |
+ |
+ while (true) { |
+ try { |
+ return await readBuildResultFromHttp(_client, buildUri, timeout); |
+ } on TimeoutException { |
+ if (timeout != null) { |
+ skipToPreviousBuildNumber(); |
+ continue; |
+ } |
+ return null; |
+ } on HttpException { |
+ if (timeout != null) { |
+ skipToPreviousBuildNumber(); |
+ continue; |
+ } |
+ return null; |
+ } on SocketException { |
+ return null; |
+ } |
} |
} |
- int get mostRecentBuildNumber => -2; |
+ int get mostRecentBuildNumber => -1; |
@override |
void close() { |