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

Unified Diff: sdk/lib/_internal/pub/lib/src/entrypoint.dart

Issue 357483004: Split installing a package locally from symlinking to it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise! Created 6 years, 6 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 | « no previous file | sdk/lib/_internal/pub/lib/src/source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/entrypoint.dart
diff --git a/sdk/lib/_internal/pub/lib/src/entrypoint.dart b/sdk/lib/_internal/pub/lib/src/entrypoint.dart
index a2c669b13ce5656b6f0f27061cbe68bdd7556f89..3eeeebd1d43d8127bb83102eae169d39e064eec3 100644
--- a/sdk/lib/_internal/pub/lib/src/entrypoint.dart
+++ b/sdk/lib/_internal/pub/lib/src/entrypoint.dart
@@ -65,41 +65,6 @@ class Entrypoint {
/// The path to the entrypoint package's lockfile.
String get lockFilePath => path.join(root.dir, 'pubspec.lock');
- /// Gets package [id] and makes it available for use by this entrypoint.
- ///
- /// If this completes successfully, the package is guaranteed to be importable
- /// using the `package:` scheme. Returns the resolved [PackageId].
- ///
- /// This automatically downloads the package to the system-wide cache as well
- /// if it requires network access to retrieve (specifically, if the package's
- /// source is a [CachedSource]).
- ///
- /// See also [getDependencies].
- Future<PackageId> get(PackageId id) {
- var pending = _pendingGets[id];
- if (pending != null) return pending;
-
- var packageDir = path.join(packagesDir, id.name);
-
- var future = syncFuture(() {
- ensureDir(path.dirname(packageDir));
-
- if (entryExists(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 get.");
- deleteEntry(packageDir);
- }
-
- var source = cache.sources[id.source];
- return source.get(id, packageDir).then((_) => source.resolveId(id));
- });
-
- _pendingGets[id] = future;
-
- return future;
- }
-
/// Gets all dependencies of the [root] package.
///
/// [useLatest], if provided, defines a list of packages that will be
@@ -129,10 +94,7 @@ class Entrypoint {
// Install the packages.
cleanDir(packagesDir);
- return Future.wait(result.packages.map((id) {
- if (id.isRoot) return new Future.value(id);
- return get(id);
- }).toList()).then((ids) {
+ return Future.wait(result.packages.map(_get).toList()).then((ids) {
_saveLockFile(ids);
_linkSelf();
_linkSecondaryPackageDirs();
@@ -141,6 +103,30 @@ class Entrypoint {
});
}
+ /// Makes sure the package at [id] is locally available.
+ ///
+ /// This automatically downloads the package to the system-wide cache as well
+ /// if it requires network access to retrieve (specifically, if the package's
+ /// source is a [CachedSource]).
+ Future<PackageId> _get(PackageId id) {
+ if (id.isRoot) return new Future.value(id);
+
+ var pending = _pendingGets[id];
+ if (pending != null) return pending;
+
+ var future = syncFuture(() {
+ var packageDir = path.join(packagesDir, id.name);
+ if (entryExists(packageDir)) deleteEntry(packageDir);
+
+ var source = cache.sources[id.source];
+ return source.get(id, packageDir).then((_) => source.resolveId(id));
+ });
+
+ _pendingGets[id] = future;
+
+ return future;
+ }
+
/// Loads the list of concrete package versions from the `pubspec.lock`, if it
/// exists.
///
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698