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

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

Issue 521643005: Convert more pub code to use async/await. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise! Created 6 years, 3 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 | « sdk/lib/_internal/pub/bin/pub.dart ('k') | sdk/lib/_internal/pub/lib/src/command/downgrade.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_repair.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command/cache_repair.dart b/sdk/lib/_internal/pub/lib/src/command/cache_repair.dart
index b16efe2f77bae181b151a9b8818fc534a14874b8..dfeab5eaa55f085668d51f093b5ed140db28f3ef 100644
--- a/sdk/lib/_internal/pub/lib/src/command/cache_repair.dart
+++ b/sdk/lib/_internal/pub/lib/src/command/cache_repair.dart
@@ -19,33 +19,33 @@ class CacheRepairCommand extends PubCommand {
String get usage => "pub cache repair";
String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-cache.html";
- Future onRun() {
+ Future onRun() async {
var successes = 0;
var failures = 0;
// Repair every cached source.
- return Future.forEach(cache.sources.where(
- (source) => source is CachedSource), (source) {
- return source.repairCachedPackages().then((results) {
- successes += results.first;
- failures += results.last;
- });
- }).then((_) {
- if (successes > 0) {
- var packages = pluralize("package", successes);
- log.message("Reinstalled ${log.green(successes)} $packages.");
- }
-
- if (failures > 0) {
- var packages = pluralize("package", failures);
- log.message("Failed to reinstall ${log.red(failures)} $packages.");
- }
-
- if (successes == 0 && failures == 0) {
- log.message("No packages in cache, so nothing to repair.");
- }
-
- if (failures > 0) return flushThenExit(exit_codes.UNAVAILABLE);
- });
+ for (var source in cache.sources) {
+ if (source is! CachedSource) continue;
+
+ var results = await source.repairCachedPackages();
+ successes += results.first;
+ failures += results.last;
+ }
+
+ if (successes > 0) {
+ var packages = pluralize("package", successes);
+ log.message("Reinstalled ${log.green(successes)} $packages.");
+ }
+
+ if (failures > 0) {
+ var packages = pluralize("package", failures);
+ log.message("Failed to reinstall ${log.red(failures)} $packages.");
+ }
+
+ if (successes == 0 && failures == 0) {
+ log.message("No packages in cache, so nothing to repair.");
+ }
+
+ if (failures > 0) await flushThenExit(exit_codes.UNAVAILABLE);
}
}
« no previous file with comments | « sdk/lib/_internal/pub/bin/pub.dart ('k') | sdk/lib/_internal/pub/lib/src/command/downgrade.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698