| OLD | NEW |
| 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 'package:path/path.dart' as path; | 7 import 'package:path/path.dart' as path; |
| 8 | 8 |
| 9 import '../io.dart'; | 9 import '../io.dart'; |
| 10 import '../package.dart'; | 10 import '../package.dart'; |
| 11 import '../pubspec.dart'; | 11 import '../pubspec.dart'; |
| 12 import '../source.dart'; | 12 import '../source.dart'; |
| 13 import '../utils.dart'; | 13 import '../utils.dart'; |
| 14 | 14 |
| 15 /// Base class for a [Source] that installs packages into pub's [SystemCache]. | 15 /// Base class for a [BoundSource] that installs packages into pub's |
| 16 /// [SystemCache]. |
| 16 /// | 17 /// |
| 17 /// A source should be cached if it requires network access to retrieve | 18 /// A source should be cached if it requires network access to retrieve |
| 18 /// packages or the package needs to be "frozen" at the point in time that it's | 19 /// packages or the package needs to be "frozen" at the point in time that it's |
| 19 /// installed. (For example, Git packages are cached because installing from | 20 /// installed. (For example, Git packages are cached because installing from |
| 20 /// the same repo over time may yield different commits.) | 21 /// the same repo over time may yield different commits.) |
| 21 abstract class CachedSource extends Source { | 22 abstract class CachedSource extends BoundSource { |
| 22 /// The root directory of this source's cache within the system cache. | 23 /// The root directory of this source's cache within the system cache. |
| 23 /// | 24 /// |
| 24 /// This shouldn't be overridden by subclasses. | 25 /// This shouldn't be overridden by subclasses. |
| 25 String get systemCacheRoot => path.join(systemCache.rootDir, name); | 26 String get systemCacheRoot => path.join(systemCache.rootDir, source.name); |
| 26 | 27 |
| 27 /// If [id] is already in the system cache, just loads it from there. | 28 /// If [id] is already in the system cache, just loads it from there. |
| 28 /// | 29 /// |
| 29 /// Otherwise, defers to the subclass. | 30 /// Otherwise, defers to the subclass. |
| 30 Future<Pubspec> doDescribe(PackageId id) async { | 31 Future<Pubspec> doDescribe(PackageId id) async { |
| 31 var packageDir = getDirectory(id); | 32 var packageDir = getDirectory(id); |
| 32 if (fileExists(path.join(packageDir, "pubspec.yaml"))) { | 33 if (fileExists(path.join(packageDir, "pubspec.yaml"))) { |
| 33 return new Pubspec.load(packageDir, systemCache.sources, | 34 return new Pubspec.load(packageDir, systemCache.sources, |
| 34 expectedName: id.name); | 35 expectedName: id.name); |
| 35 } | 36 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 61 List<Package> getCachedPackages(); | 62 List<Package> getCachedPackages(); |
| 62 | 63 |
| 63 /// Reinstalls all packages that have been previously installed into the | 64 /// Reinstalls all packages that have been previously installed into the |
| 64 /// system cache by this source. | 65 /// system cache by this source. |
| 65 /// | 66 /// |
| 66 /// Returns a [Pair] whose first element is the packages that were | 67 /// Returns a [Pair] whose first element is the packages that were |
| 67 /// successfully repaired and the second is the packages that failed to be | 68 /// successfully repaired and the second is the packages that failed to be |
| 68 /// repaired. | 69 /// repaired. |
| 69 Future<Pair<List<PackageId>, List<PackageId>>> repairCachedPackages(); | 70 Future<Pair<List<PackageId>, List<PackageId>>> repairCachedPackages(); |
| 70 } | 71 } |
| OLD | NEW |