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

Side by Side Diff: lib/src/source/hosted.dart

Issue 1239623005: "pub cache repair" prints a more detailed summary. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 5 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/source/git.dart ('k') | test/cache/repair/handles_corrupted_global_lockfile_test.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library pub.source.hosted; 5 library pub.source.hosted;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io' as io; 8 import 'dart:io' as io;
9 import "dart:convert"; 9 import "dart:convert";
10 10
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 /// given name from the default host, while a map with keys "name" and "url" 118 /// given name from the default host, while a map with keys "name" and "url"
119 /// refers to a package with the given name from the host at the given URL. 119 /// refers to a package with the given name from the host at the given URL.
120 dynamic parseDescription(String containingPath, description, 120 dynamic parseDescription(String containingPath, description,
121 {bool fromLockFile: false}) { 121 {bool fromLockFile: false}) {
122 _parseDescription(description); 122 _parseDescription(description);
123 return description; 123 return description;
124 } 124 }
125 125
126 /// Re-downloads all packages that have been previously downloaded into the 126 /// Re-downloads all packages that have been previously downloaded into the
127 /// system cache from any server. 127 /// system cache from any server.
128 Future<Pair<int, int>> repairCachedPackages() async { 128 Future<Pair<List<PackageId>, List<PackageId>>> repairCachedPackages() async {
129 if (!dirExists(systemCacheRoot)) return new Pair(0, 0); 129 if (!dirExists(systemCacheRoot)) return new Pair([], []);
130 130
131 var successes = 0; 131 var successes = [];
132 var failures = 0; 132 var failures = [];
133 133
134 for (var serverDir in listDir(systemCacheRoot)) { 134 for (var serverDir in listDir(systemCacheRoot)) {
135 var url = _directoryToUrl(path.basename(serverDir)); 135 var url = _directoryToUrl(path.basename(serverDir));
136 var packages = _getCachedPackagesInDirectory(path.basename(serverDir)); 136 var packages = _getCachedPackagesInDirectory(path.basename(serverDir));
137 packages.sort(Package.orderByNameAndVersion); 137 packages.sort(Package.orderByNameAndVersion);
138 138
139 for (var package in packages) { 139 for (var package in packages) {
140 var id = new PackageId(package.name, this.name, package.version, null);
141
140 try { 142 try {
141 await _download(url, package.name, package.version, package.dir); 143 await _download(url, package.name, package.version, package.dir);
142 successes++; 144 successes.add(id);
143 } catch (error, stackTrace) { 145 } catch (error, stackTrace) {
144 failures++; 146 failures.add(id);
145 var message = "Failed to repair ${log.bold(package.name)} " 147 var message = "Failed to repair ${log.bold(package.name)} "
146 "${package.version}"; 148 "${package.version}";
147 if (url != defaultUrl) message += " from $url"; 149 if (url != defaultUrl) message += " from $url";
148 log.error("$message. Error:\n$error"); 150 log.error("$message. Error:\n$error");
149 log.fine(stackTrace); 151 log.fine(stackTrace);
150 152
151 tryDeleteEntry(package.dir); 153 tryDeleteEntry(package.dir);
152 } 154 }
153 } 155 }
154 } 156 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 var name = description["name"]; 349 var name = description["name"];
348 if (name is! String) { 350 if (name is! String) {
349 throw new FormatException("The 'name' key must have a string value."); 351 throw new FormatException("The 'name' key must have a string value.");
350 } 352 }
351 353
352 var url = description["url"]; 354 var url = description["url"];
353 if (url == null) url = HostedSource.defaultUrl; 355 if (url == null) url = HostedSource.defaultUrl;
354 356
355 return new Pair<String, String>(name, url); 357 return new Pair<String, String>(name, url);
356 } 358 }
OLDNEW
« no previous file with comments | « lib/src/source/git.dart ('k') | test/cache/repair/handles_corrupted_global_lockfile_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698