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

Side by Side Diff: lib/src/command/cache_repair.dart

Issue 2044253003: Refactor Source and SourceRegistry. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Rename LiveSource to BoundSource. Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « lib/src/command/cache_list.dart ('k') | lib/src/command/lish.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 import '../command.dart'; 7 import '../command.dart';
8 import '../exit_codes.dart' as exit_codes; 8 import '../exit_codes.dart' as exit_codes;
9 import '../io.dart'; 9 import '../io.dart';
10 import '../log.dart' as log; 10 import '../log.dart' as log;
11 import '../source/cached.dart'; 11 import '../source/cached.dart';
12 import '../utils.dart'; 12 import '../utils.dart';
13 13
14 /// Handles the `cache repair` pub command. 14 /// Handles the `cache repair` pub command.
15 class CacheRepairCommand extends PubCommand { 15 class CacheRepairCommand extends PubCommand {
16 String get name => "repair"; 16 String get name => "repair";
17 String get description => "Reinstall cached packages."; 17 String get description => "Reinstall cached packages.";
18 String get invocation => "pub cache repair"; 18 String get invocation => "pub cache repair";
19 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-cache.html"; 19 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-cache.html";
20 bool get takesArguments => false; 20 bool get takesArguments => false;
21 21
22 Future run() async { 22 Future run() async {
23 var successes = []; 23 var successes = [];
24 var failures = []; 24 var failures = [];
25 25
26 // Repair every cached source. 26 // Repair every cached source.
27 for (var source in cache.sources) { 27 for (var source in cache.sources.all
28 .map((source) => cache.source(source.name))) {
28 if (source is! CachedSource) continue; 29 if (source is! CachedSource) continue;
29 30
30 var results = await source.repairCachedPackages(); 31 var results = await source.repairCachedPackages();
31 successes.addAll(results.first); 32 successes.addAll(results.first);
32 failures.addAll(results.last); 33 failures.addAll(results.last);
33 } 34 }
34 35
35 if (successes.length > 0) { 36 if (successes.length > 0) {
36 var packages = pluralize("package", successes.length); 37 var packages = pluralize("package", successes.length);
37 log.message("Reinstalled ${log.green(successes.length)} $packages."); 38 log.message("Reinstalled ${log.green(successes.length)} $packages.");
(...skipping 30 matching lines...) Expand all
68 69
69 if (successes.length == 0 && failures.length == 0) { 70 if (successes.length == 0 && failures.length == 0) {
70 log.message("No packages in cache, so nothing to repair."); 71 log.message("No packages in cache, so nothing to repair.");
71 } 72 }
72 73
73 if (failures.length > 0 || results.last.length > 0) { 74 if (failures.length > 0 || results.last.length > 0) {
74 await flushThenExit(exit_codes.UNAVAILABLE); 75 await flushThenExit(exit_codes.UNAVAILABLE);
75 } 76 }
76 } 77 }
77 } 78 }
OLDNEW
« no previous file with comments | « lib/src/command/cache_list.dart ('k') | lib/src/command/lish.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698