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

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

Issue 15347004: Gracefully handle pubspecs with dependencies using unknown sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests for unknown sources in lockfiles. Created 7 years, 7 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
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source.dart ('k') | sdk/lib/_internal/pub/lib/src/validator/dependency.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 567803bbe46e95f3c544d8b4ca0dde4eed4d0268..63de5dc59899e0acff87082e84ad415d82eebbf1 100644
--- a/sdk/lib/_internal/pub/lib/src/system_cache.dart
+++ b/sdk/lib/_internal/pub/lib/src/system_cache.dart
@@ -70,41 +70,25 @@ class SystemCache {
sources.register(source);
}
- /// Gets the package identified by [id]. If the package is already cached,
- /// reads it from the cache. Otherwise, requests it from the source.
- Future<Pubspec> describe(PackageId id) {
- if (id.isRoot) throw new ArgumentError("Cannot describe the root package.");
-
- // Try to get it from the system cache first.
- if (id.source.shouldCache) {
- return id.systemCacheDirectory.then((packageDir) {
- if (!fileExists(path.join(packageDir, "pubspec.yaml"))) {
- return id.source.describe(id);
- }
-
- return new Pubspec.load(id.name, packageDir, sources);
- });
- }
-
- // Not cached, so get it from the source.
- return id.source.describe(id);
- }
-
/// Ensures that the package identified by [id] is installed to the cache,
/// loads it, and returns it.
///
- /// It is an error to try installing a package from a source with `shouldCache
- /// == false` to the system cache.
+ /// It is an error to try installing a package from a source with
+ /// `shouldCache == false` to the system cache.
Future<Package> install(PackageId id) {
- if (!id.source.shouldCache) {
+ var source = sources[id.source];
+
+ if (!source.shouldCache) {
throw new ArgumentError("Package $id is not cacheable.");
}
var pending = _pendingInstalls[id];
if (pending != null) return pending;
- var future = id.source.installToSystemCache(id)
- .whenComplete(() { _pendingInstalls.remove(id); });
+ var future = source.installToSystemCache(id).whenComplete(() {
+ _pendingInstalls.remove(id);
+ });
+
_pendingInstalls[id] = future;
return future;
}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source.dart ('k') | sdk/lib/_internal/pub/lib/src/validator/dependency.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698