| OLD | NEW |
| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io' as io; | 6 import 'dart:io' as io; |
| 7 import "dart:convert"; | 7 import "dart:convert"; |
| 8 | 8 |
| 9 import 'package:http/http.dart' as http; | 9 import 'package:http/http.dart' as http; |
| 10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 var parsed = source._parseDescription(id.description); | 205 var parsed = source._parseDescription(id.description); |
| 206 var dir = _urlToDirectory(parsed.last); | 206 var dir = _urlToDirectory(parsed.last); |
| 207 return p.join(systemCacheRoot, dir, "${parsed.first}-${id.version}"); | 207 return p.join(systemCacheRoot, dir, "${parsed.first}-${id.version}"); |
| 208 } | 208 } |
| 209 | 209 |
| 210 /// Re-downloads all packages that have been previously downloaded into the | 210 /// Re-downloads all packages that have been previously downloaded into the |
| 211 /// system cache from any server. | 211 /// system cache from any server. |
| 212 Future<Pair<List<PackageId>, List<PackageId>>> repairCachedPackages() async { | 212 Future<Pair<List<PackageId>, List<PackageId>>> repairCachedPackages() async { |
| 213 if (!dirExists(systemCacheRoot)) return new Pair([], []); | 213 if (!dirExists(systemCacheRoot)) return new Pair([], []); |
| 214 | 214 |
| 215 var successes = []; | 215 var successes = <PackageId>[]; |
| 216 var failures = []; | 216 var failures = <PackageId>[]; |
| 217 | 217 |
| 218 for (var serverDir in listDir(systemCacheRoot)) { | 218 for (var serverDir in listDir(systemCacheRoot)) { |
| 219 var url = _directoryToUrl(p.basename(serverDir)); | 219 var url = _directoryToUrl(p.basename(serverDir)); |
| 220 var packages = _getCachedPackagesInDirectory(p.basename(serverDir)); | 220 var packages = _getCachedPackagesInDirectory(p.basename(serverDir)); |
| 221 packages.sort(Package.orderByNameAndVersion); | 221 packages.sort(Package.orderByNameAndVersion); |
| 222 | 222 |
| 223 for (var package in packages) { | 223 for (var package in packages) { |
| 224 var id = source.idFor(package.name, package.version, url: url); | 224 var id = source.idFor(package.name, package.version, url: url); |
| 225 | 225 |
| 226 try { | 226 try { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 // Since HostedSource is cached, this will only be called for uncached | 419 // Since HostedSource is cached, this will only be called for uncached |
| 420 // packages. | 420 // packages. |
| 421 throw new UnsupportedError("Cannot download packages when offline."); | 421 throw new UnsupportedError("Cannot download packages when offline."); |
| 422 } | 422 } |
| 423 | 423 |
| 424 Future<Pubspec> describeUncached(PackageId id) { | 424 Future<Pubspec> describeUncached(PackageId id) { |
| 425 throw new PackageNotFoundException( | 425 throw new PackageNotFoundException( |
| 426 "${id.name} ${id.version} is not available in your system cache."); | 426 "${id.name} ${id.version} is not available in your system cache."); |
| 427 } | 427 } |
| 428 } | 428 } |
| OLD | NEW |