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

Unified Diff: sdk/lib/_internal/pub/lib/src/source/hosted.dart

Issue 745153002: Make pub's binstubs resilient to changes in snapshot format. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years 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
Index: sdk/lib/_internal/pub/lib/src/source/hosted.dart
diff --git a/sdk/lib/_internal/pub/lib/src/source/hosted.dart b/sdk/lib/_internal/pub/lib/src/source/hosted.dart
index 3bb0ea14bfa1ab075996a807def53c3da6c6432a..825a87257384c62e6834b01a23c925754a16ff73 100644
--- a/sdk/lib/_internal/pub/lib/src/source/hosted.dart
+++ b/sdk/lib/_internal/pub/lib/src/source/hosted.dart
@@ -124,30 +124,34 @@ class HostedSource extends CachedSource {
/// Re-downloads all packages that have been previously downloaded into the
/// system cache from any server.
- Future<Pair<int, int>> repairCachedPackages() {
- if (!dirExists(systemCacheRoot)) return new Future.value(new Pair(0, 0));
+ Future<Pair<int, int>> repairCachedPackages() async {
+ if (!dirExists(systemCacheRoot)) return new Pair(0, 0);
var successes = 0;
var failures = 0;
- return Future.wait(listDir(systemCacheRoot).map((serverDir) {
+ for (var serverDir in listDir(systemCacheRoot)) {
var url = _directoryToUrl(path.basename(serverDir));
var packages = _getCachedPackagesInDirectory(path.basename(serverDir));
packages.sort(Package.orderByNameAndVersion);
- return Future.wait(packages.map((package) {
- return _download(url, package.name, package.version, package.dir)
- .then((_) {
+ for (var package in packages) {
+ try {
+ await _download(url, package.name, package.version, package.dir);
successes++;
- }).catchError((error, stackTrace) {
+ } catch (error, stackTrace) {
failures++;
var message = "Failed to repair ${log.bold(package.name)} "
"${package.version}";
if (url != defaultUrl) message += " from $url";
log.error("$message. Error:\n$error");
log.fine(stackTrace);
- });
- }));
- })).then((_) => new Pair(successes, failures));
+
+ tryDeleteEntry(package.dir);
+ }
+ }
+ }
+
+ return new Pair(successes, failures);
}
/// Gets all of the packages that have been downloaded into the system cache

Powered by Google App Engine
This is Rietveld 408576698