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

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

Issue 136063005: Add a "cache add" command to download packages to the cache. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
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) {
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/solver/version_solver.dart ('k') | sdk/lib/_internal/pub/lib/src/system_cache.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698