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

Unified Diff: sdk/lib/_internal/pub/lib/src/command/cache_add.dart

Issue 1113363004: Cache pubspecs when HostedSource.getVersions is called. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 7 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 | « no previous file | sdk/lib/_internal/pub/lib/src/solver/version_solver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/command/cache_add.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command/cache_add.dart b/sdk/lib/_internal/pub/lib/src/command/cache_add.dart
index 453ccbd0957a54bb0667880bf078c48d69220ac4..ae5c1da8bc55e46aa7554afbf278749faaca11a7 100644
--- a/sdk/lib/_internal/pub/lib/src/command/cache_add.dart
+++ b/sdk/lib/_internal/pub/lib/src/command/cache_add.dart
@@ -30,7 +30,7 @@ class CacheAddCommand extends PubCommand {
help: "Version constraint.");
}
- Future run() {
+ Future run() async {
// Make sure there is a package.
if (argResults.rest.isEmpty) {
usageException("No package to add given.");
@@ -59,38 +59,36 @@ class CacheAddCommand extends PubCommand {
var source = cache.sources["hosted"];
// TODO(rnystrom): Allow specifying the server.
- return source.getVersions(package, package).then((versions) {
- versions = versions.where(constraint.allows).toList();
+ var pubspecs = await source.getVersions(package, package);
+ var versions = pubspecs.map((pubspec) => pubspec.version)
+ .where(constraint.allows).toList();
- if (versions.isEmpty) {
- // TODO(rnystrom): Show most recent unmatching version?
- fail("Package $package has no versions that match $constraint.");
- }
+ if (versions.isEmpty) {
+ // TODO(rnystrom): Show most recent unmatching version?
+ fail("Package $package has no versions that match $constraint.");
+ }
- downloadVersion(Version version) {
- var id = new PackageId(package, source.name, version, package);
- return cache.contains(id).then((contained) {
- if (contained) {
- // TODO(rnystrom): Include source and description if not hosted.
- // See solve_report.dart for code to harvest.
- log.message("Already cached ${id.name} ${id.version}.");
- return null;
- }
-
- // Download it.
- return source.downloadToSystemCache(id);
- });
+ downloadVersion(version) async {
+ var id = new PackageId(package, source.name, version, package);
+ if (await cache.contains(id)) {
+ // TODO(rnystrom): Include source and description if not hosted.
+ // See solve_report.dart for code to harvest.
+ log.message("Already cached ${id.name} ${id.version}.");
+ return null;
}
- if (argResults["all"]) {
- // Install them in ascending order.
- versions.sort();
- return Future.forEach(versions, downloadVersion);
- } else {
- // Pick the best matching version.
- versions.sort(Version.prioritize);
- return downloadVersion(versions.last);
- }
- });
+ // Download it.
+ await source.downloadToSystemCache(id);
+ }
+
+ if (argResults["all"]) {
+ // Install them in ascending order.
+ versions.sort();
+ await Future.forEach(versions, downloadVersion);
+ } else {
+ // Pick the best matching version.
+ versions.sort(Version.prioritize);
+ await downloadVersion(versions.last);
+ }
}
}
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/solver/version_solver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698