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 |