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

Unified Diff: utils/pub/source.dart

Issue 13332009: Make listDir and createSymlink synchronous in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 9 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/path_source.dart ('k') | utils/pub/utils.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 109b5b2a3f07564cb15ddb23e08191e0ffb2836f..adb95714279c87adc8fc5484255916918eae5bca 100644
--- a/utils/pub/source.dart
+++ b/utils/pub/source.dart
@@ -113,17 +113,12 @@ abstract class Source {
packageDir = p;
// See if it's already cached.
- if (!dirExists(packageDir)) return false;
-
- return _isCachedPackageCorrupted(packageDir).then((isCorrupted) {
- if (!isCorrupted) return true;
-
+ if (dirExists(packageDir)) {
+ if (!_isCachedPackageCorrupted(packageDir)) return true;
// Busted, so wipe out the package and reinstall.
deleteEntry(packageDir);
- return false;
- });
- }).then((isInstalled) {
- if (isInstalled) return true;
+ }
+
ensureDir(path.dirname(packageDir));
return install(id, packageDir);
}).then((found) {
@@ -143,18 +138,14 @@ abstract class Source {
///
/// * It has an empty "lib" directory.
/// * It has no pubspec.
- Future<bool> _isCachedPackageCorrupted(String packageDir) {
- return defer(() {
- if (!fileExists(path.join(packageDir, "pubspec.yaml"))) return true;
+ bool _isCachedPackageCorrupted(String packageDir) {
+ if (!fileExists(path.join(packageDir, "pubspec.yaml"))) return true;
- var libDir = path.join(packageDir, "lib");
- if (dirExists(libDir)) {
- return listDir(libDir).then((contents) => contents.length == 0);
- }
+ var libDir = path.join(packageDir, "lib");
+ if (dirExists(libDir)) return listDir(libDir).length == 0;
- // If we got here, it's OK.
- return false;
- });
+ // If we got here, it's OK.
+ return false;
}
/// Returns the directory in the system cache that the package identified by
@@ -218,7 +209,7 @@ abstract class Source {
Future<PackageId> resolveId(PackageId id) => new Future.immediate(id);
/// Returns the [Package]s that have been installed in the system cache.
- Future<List<Package>> getCachedPackages() {
+ List<Package> getCachedPackages() {
if (shouldCache) throw "Source $name must implement this.";
}
« no previous file with comments | « utils/pub/path_source.dart ('k') | utils/pub/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698