| Index: sdk/lib/_internal/pub/lib/src/system_cache.dart
|
| diff --git a/sdk/lib/_internal/pub/lib/src/system_cache.dart b/sdk/lib/_internal/pub/lib/src/system_cache.dart
|
| index 9cfca43046c3c820b8b6f75b105a8f162e1e4711..4c48fbad859612912fca43d9125b477a4f2cbb4d 100644
|
| --- a/sdk/lib/_internal/pub/lib/src/system_cache.dart
|
| +++ b/sdk/lib/_internal/pub/lib/src/system_cache.dart
|
| @@ -12,6 +12,7 @@ import 'io.dart';
|
| import 'io.dart' as io show createTempDir;
|
| import 'log.dart' as log;
|
| import 'package.dart';
|
| +import 'source/cached.dart';
|
| import 'source/git.dart';
|
| import 'source/hosted.dart';
|
| import 'source/path.dart';
|
| @@ -29,17 +30,12 @@ class SystemCache {
|
|
|
| String get tempDir => path.join(rootDir, '_temp');
|
|
|
| - /// Packages which are currently being asynchronously downloaded to the cache.
|
| - final Map<PackageId, Future<Package>> _pendingDownloads;
|
| -
|
| /// The sources from which to get packages.
|
| - final SourceRegistry sources;
|
| + final sources = new SourceRegistry();
|
|
|
| /// Creates a new package cache which is backed by the given directory on the
|
| /// user's file system.
|
| - SystemCache(this.rootDir)
|
| - : _pendingDownloads = new Map<PackageId, Future<Package>>(),
|
| - sources = new SourceRegistry();
|
| + SystemCache(this.rootDir);
|
|
|
| /// Creates a system cache and registers the standard set of sources. If
|
| /// [isOffline] is `true`, then the offline hosted source will be used.
|
| @@ -70,40 +66,13 @@ class SystemCache {
|
| Future<bool> contains(PackageId id) {
|
| var source = sources[id.source];
|
|
|
| - if (!source.shouldCache) {
|
| + if (source is! CachedSource) {
|
| throw new ArgumentError("Package $id is not cacheable.");
|
| }
|
|
|
| return source.isInSystemCache(id);
|
| }
|
|
|
| - /// Ensures that the package identified by [id] is downloaded to the cache,
|
| - /// loads it, and returns it.
|
| - ///
|
| - /// It is an error to try downloading a package from a source with
|
| - /// `shouldCache == false`.
|
| - ///
|
| - /// If [force] is `true`, then the package is downloaded even if it already
|
| - /// exists in the cache. The previous one will be deleted.
|
| - Future<Package> download(PackageId id, {bool force}) {
|
| - var source = sources[id.source];
|
| -
|
| - if (!source.shouldCache) {
|
| - throw new ArgumentError("Package $id is not cacheable.");
|
| - }
|
| -
|
| - var pending = _pendingDownloads[id];
|
| - if (pending != null) return pending;
|
| -
|
| - var future = source.downloadToSystemCache(id, force: force)
|
| - .whenComplete(() {
|
| - _pendingDownloads.remove(id);
|
| - });
|
| -
|
| - _pendingDownloads[id] = future;
|
| - return future;
|
| - }
|
| -
|
| /// Create a new temporary directory within the system cache. The system
|
| /// cache maintains its own temporary directory that it uses to stage
|
| /// packages into while downloading. It uses this instead of the OS's system
|
|
|