Chromium Code Reviews| Index: utils/pub/entrypoint.dart |
| diff --git a/utils/pub/entrypoint.dart b/utils/pub/entrypoint.dart |
| index a6afb14a2109bce79ffd3a9b0aef6481ef243e1c..a190c1ba3cdb6be618a7f8a270ffc4909d47a96c 100644 |
| --- a/utils/pub/entrypoint.dart |
| +++ b/utils/pub/entrypoint.dart |
| @@ -73,13 +73,14 @@ class Entrypoint { |
| var packageDir = path.join(packagesDir, id.name); |
| var future = defer(() { |
| ensureDir(path.dirname(packageDir)); |
| - if (!dirExists(packageDir)) return; |
| - // TODO(nweiz): figure out when to actually delete the directory, and when |
| - // we can just re-use the existing symlink. |
| - log.fine("Deleting package directory for ${id.name} before install."); |
| - return deleteDir(packageDir); |
| - }).then((_) { |
| + if (dirExists(packageDir)) { |
| + // TODO(nweiz): figure out when to actually delete the directory, and |
| + // when we can just re-use the existing symlink. |
| + log.fine("Deleting package directory for ${id.name} before install."); |
| + deleteDir(packageDir); |
| + } |
| + |
| if (id.source.shouldCache) { |
| return cache.install(id).then( |
| (pkg) => createPackageSymlink(id.name, pkg.dir, packageDir)); |
| @@ -130,7 +131,8 @@ class Entrypoint { |
| /// Removes the old packages directory, installs all dependencies listed in |
| /// [packageVersions], and writes a [LockFile]. |
| Future _installDependencies(List<PackageId> packageVersions) { |
| - return cleanDir(packagesDir).then((_) { |
| + return new Future.of(() { |
|
Bob Nystrom
2013/03/20 16:33:42
For consistency's sake, how about using defer() he
nweiz
2013/03/20 19:45:46
Done, although I think we should remove defer() at
Bob Nystrom
2013/03/20 19:49:34
I'm fine with that (though defer() is a good bit m
|
| + cleanDir(packagesDir); |
| return Future.wait(packageVersions.map((id) { |
| if (id.isRoot) return new Future.immediate(id); |
| return install(id); |
| @@ -296,13 +298,12 @@ class Entrypoint { |
| Future _linkSecondaryPackageDir(String dir) { |
| return defer(() { |
| var symlink = path.join(dir, 'packages'); |
| - return new Future.of(() { |
| - if (fileExists(symlink)) { |
| - deleteFile(symlink); |
| - } else if (dirExists(symlink)) { |
| - return deleteDir(symlink); |
| - } |
| - }).then((_) => createSymlink(packagesDir, symlink, relative: true)); |
| + if (fileExists(symlink)) { |
| + deleteFile(symlink); |
| + } else if (dirExists(symlink)) { |
| + deleteDir(symlink); |
| + } |
| + return createSymlink(packagesDir, symlink, relative: true); |
| }); |
| } |
| } |