Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Unified Diff: utils/pub/hosted_source.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/git_source.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/hosted_source.dart
diff --git a/utils/pub/hosted_source.dart b/utils/pub/hosted_source.dart
index 4b515aca4f2f5571015a3f337fb3f005b62db6e6..45867e5f924316a02b9d17e9460572780400f5b5 100644
--- a/utils/pub/hosted_source.dart
+++ b/utils/pub/hosted_source.dart
@@ -4,8 +4,9 @@
library hosted_source;
+import 'dart:async';
import 'dart:io' as io;
-import 'dart:json';
+import 'dart:json' as json;
import 'dart:uri';
// TODO(nweiz): Make this import better.
@@ -35,9 +36,11 @@ class HostedSource extends Source {
var parsed = _parseDescription(description);
var fullUrl = "${parsed.last}/packages/${parsed.first}.json";
- return httpClient.read(fullUrl).transform((body) {
- var doc = JSON.parse(body);
- return doc['versions'].map((version) => new Version.parse(version));
+ return httpClient.read(fullUrl).then((body) {
+ var doc = json.parse(body);
+ return doc['versions']
+ .mappedBy((version) => new Version.parse(version))
+ .toList();
}).transformException((ex) {
_throwFriendlyError(ex, parsed.first, parsed.last);
});
@@ -50,7 +53,7 @@ class HostedSource extends Source {
var fullUrl = "${parsed.last}/packages/${parsed.first}/versions/"
"${id.version}.yaml";
- return httpClient.read(fullUrl).transform((yaml) {
+ return httpClient.read(fullUrl).then((yaml) {
return new Pubspec.parse(yaml, systemCache.sources);
}).transformException((ex) {
_throwFriendlyError(ex, id, parsed.last);
@@ -71,18 +74,18 @@ class HostedSource extends Source {
var tempDir;
return Futures.wait([
httpClient.send(new http.Request("GET", new Uri.fromString(fullUrl)))
- .transform((response) => response.stream),
+ .then((response) => response.stream),
systemCache.createTempDir()
- ]).chain((args) {
+ ]).then((args) {
tempDir = args[1];
return timeout(extractTarGz(args[0], tempDir), HTTP_TIMEOUT,
'fetching URL "$fullUrl"');
- }).chain((_) {
+ }).then((_) {
// Now that the install has succeeded, move it to the real location in
// the cache. This ensures that we don't leave half-busted ghost
// directories in the user's pub cache if an install fails.
return renameDir(tempDir, destPath);
- }).transform((_) => true);
+ }).then((_) => true);
}
/// The system cache directory for the hosted source contains subdirectories
« no previous file with comments | « utils/pub/git_source.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698