Index: sdk/lib/_internal/pub/lib/src/source.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/source.dart b/sdk/lib/_internal/pub/lib/src/source.dart |
index 299f6cfc75eb97f42e1c5ccf142e7132ac87c82d..4e9fac6ef0923242e6005738b4403eac66ef7603 100644 |
--- a/sdk/lib/_internal/pub/lib/src/source.dart |
+++ b/sdk/lib/_internal/pub/lib/src/source.dart |
@@ -144,10 +144,22 @@ abstract class Source { |
"be implemented for source $name."); |
} |
- /// Downloads the package identified by [id] to the system cache. This is only |
- /// called for sources with [shouldCache] set to true. |
+ /// Determines if the package with [id] is already downloaded to the system |
+ /// cache. |
/// |
- /// By default, this uses [systemCacheDirectory] and [get]. |
+ /// This should only be called for sources with [shouldCache] set to true. |
+ /// Completes to true if the package is in the cache and appears to be |
+ /// uncorrupted. |
+ Future<bool> isInSystemCache(PackageId id) { |
+ return systemCacheDirectory(id).then((packageDir) { |
+ return dirExists(packageDir) && !_isCachedPackageCorrupted(packageDir); |
+ }); |
+ } |
+ |
+ /// Downloads the package identified by [id] to the system cache. |
+ /// |
+ /// This is only called for sources with [shouldCache] set to true. By |
+ /// default, this uses [systemCacheDirectory] and [get]. |
Future<Package> downloadToSystemCache(PackageId id) { |
var packageDir; |
return systemCacheDirectory(id).then((p) { |