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

Unified Diff: utils/pub/source.dart

Issue 12092080: Validate packages against their SDK constraints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 11 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 | « utils/pub/pubspec.dart ('k') | utils/pub/system_cache.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/source.dart
diff --git a/utils/pub/source.dart b/utils/pub/source.dart
index 211f0dbad4dc342350d9714ee83e5d18d38858f0..d086374f3bffcde40dd21c2b202bcdd582bfbc80 100644
--- a/utils/pub/source.dart
+++ b/utils/pub/source.dart
@@ -104,13 +104,14 @@ abstract class Source {
///
/// By default, this uses [systemCacheDirectory] and [install].
Future<Package> installToSystemCache(PackageId id) {
- var path = systemCacheDirectory(id);
- return exists(path).then((exists) {
- if (exists) return new Future<bool>.immediate(true);
- return ensureDir(dirname(path)).then((_) => install(id, path));
- }).then((found) {
- if (!found) throw 'Package $id not found.';
- return Package.load(id.name, path, systemCache.sources);
+ return systemCacheDirectory(id).then((path) {
+ return exists(path).then((exists) {
+ if (exists) return new Future<bool>.immediate(true);
+ return ensureDir(dirname(path)).then((_) => install(id, path));
+ }).then((found) {
+ if (!found) throw 'Package $id not found.';
+ return Package.load(id.name, path, systemCache.sources);
+ });
});
}
@@ -118,11 +119,10 @@ abstract class Source {
/// [id] should be installed to. This should return a path to a subdirectory
/// of [systemCacheRoot].
///
- /// This doesn't need to be implemented if [shouldCache] is false, or if
- /// [installToSystemCache] is implemented.
- String systemCacheDirectory(PackageId id) {
- throw 'Source.systemCacheDirectory must be implemented if shouldCache is '
- 'true and installToSystemCache is not implemented.';
+ /// This doesn't need to be implemented if [shouldCache] is false.
+ Future<String> systemCacheDirectory(PackageId id) {
+ return new Future.immediateError(
+ "systemCacheDirectory() must be implemented if shouldCache is true.");
}
/// When a [Pubspec] or [LockFile] is parsed, it reads in the description for
« no previous file with comments | « utils/pub/pubspec.dart ('k') | utils/pub/system_cache.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698