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

Unified Diff: lib/src/source/cached.dart

Issue 1276673006: Make Source.getDirectory synchronous. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 4 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 | « lib/src/source.dart ('k') | lib/src/source/git.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/source/cached.dart
diff --git a/lib/src/source/cached.dart b/lib/src/source/cached.dart
index bfe0382e796e5cfb1ea787394f747cbebc011052..bdfc34cf4c2d04ecfdbfbdbaaa7dde23746c7342 100644
--- a/lib/src/source/cached.dart
+++ b/lib/src/source/cached.dart
@@ -29,15 +29,14 @@ abstract class CachedSource extends Source {
/// If [id] is already in the system cache, just loads it from there.
///
/// Otherwise, defers to the subclass.
- Future<Pubspec> doDescribe(PackageId id) {
- return getDirectory(id).then((packageDir) {
- if (fileExists(path.join(packageDir, "pubspec.yaml"))) {
- return new Pubspec.load(packageDir, systemCache.sources,
- expectedName: id.name);
- }
+ Future<Pubspec> doDescribe(PackageId id) async {
+ var packageDir = getDirectory(await resolveId(id));
+ if (fileExists(path.join(packageDir, "pubspec.yaml"))) {
+ return new Pubspec.load(packageDir, systemCache.sources,
+ expectedName: id.name);
+ }
- return describeUncached(id);
- });
+ return await describeUncached(id);
}
/// Loads the (possibly remote) pubspec for the package version identified by
@@ -55,8 +54,10 @@ abstract class CachedSource extends Source {
/// Determines if the package with [id] is already downloaded to the system
/// cache.
- Future<bool> isInSystemCache(PackageId id) =>
- getDirectory(id).then(dirExists);
+ ///
+ /// Depending on the source, this may throw an [ArgumentError] if [id] isn't
+ /// resolved using [resolveId].
+ bool isInSystemCache(PackageId id) => dirExists(getDirectory(id));
/// Downloads the package identified by [id] to the system cache.
Future<Package> downloadToSystemCache(PackageId id);
« no previous file with comments | « lib/src/source.dart ('k') | lib/src/source/git.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698