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

Side by Side Diff: utils/pub/entrypoint.dart

Issue 12879015: Provisionally stop working around issues 9252 and 9253. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/scheduled_test/test/utils.dart ('k') | utils/pub/hosted_source.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library entrypoint; 5 library entrypoint;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../../pkg/pathos/lib/path.dart' as path; 9 import '../../pkg/pathos/lib/path.dart' as path;
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 /// `id.source.shouldCache` is true). 66 /// `id.source.shouldCache` is true).
67 /// 67 ///
68 /// See also [installDependencies]. 68 /// See also [installDependencies].
69 Future<PackageId> install(PackageId id) { 69 Future<PackageId> install(PackageId id) {
70 var pendingOrCompleted = _installs[id]; 70 var pendingOrCompleted = _installs[id];
71 if (pendingOrCompleted != null) return pendingOrCompleted; 71 if (pendingOrCompleted != null) return pendingOrCompleted;
72 72
73 var packageDir = path.join(packagesDir, id.name); 73 var packageDir = path.join(packagesDir, id.name);
74 var future = defer(() { 74 var future = defer(() {
75 ensureDir(path.dirname(packageDir)); 75 ensureDir(path.dirname(packageDir));
76 if (!dirExists(packageDir)) return;
77 76
78 // TODO(nweiz): figure out when to actually delete the directory, and when 77 if (dirExists(packageDir)) {
79 // we can just re-use the existing symlink. 78 // TODO(nweiz): figure out when to actually delete the directory, and
80 log.fine("Deleting package directory for ${id.name} before install."); 79 // when we can just re-use the existing symlink.
81 return deleteDir(packageDir); 80 log.fine("Deleting package directory for ${id.name} before install.");
82 }).then((_) { 81 deleteDir(packageDir);
82 }
83
83 if (id.source.shouldCache) { 84 if (id.source.shouldCache) {
84 return cache.install(id).then( 85 return cache.install(id).then(
85 (pkg) => createPackageSymlink(id.name, pkg.dir, packageDir)); 86 (pkg) => createPackageSymlink(id.name, pkg.dir, packageDir));
86 } else { 87 } else {
87 return id.source.install(id, packageDir).then((found) { 88 return id.source.install(id, packageDir).then((found) {
88 if (found) return null; 89 if (found) return null;
89 // TODO(nweiz): More robust error-handling. 90 // TODO(nweiz): More robust error-handling.
90 throw 'Package ${id.name} not found in source "${id.source.name}".'; 91 throw 'Package ${id.name} not found in source "${id.source.name}".';
91 }); 92 });
92 } 93 }
(...skipping 30 matching lines...) Expand all
123 for (var dependency in dependencies) { 124 for (var dependency in dependencies) {
124 solver.useLatestVersion(dependency); 125 solver.useLatestVersion(dependency);
125 } 126 }
126 return solver.solve(); 127 return solver.solve();
127 }).then(_installDependencies); 128 }).then(_installDependencies);
128 } 129 }
129 130
130 /// Removes the old packages directory, installs all dependencies listed in 131 /// Removes the old packages directory, installs all dependencies listed in
131 /// [packageVersions], and writes a [LockFile]. 132 /// [packageVersions], and writes a [LockFile].
132 Future _installDependencies(List<PackageId> packageVersions) { 133 Future _installDependencies(List<PackageId> packageVersions) {
133 return cleanDir(packagesDir).then((_) { 134 return new Future.of(() {
135 cleanDir(packagesDir);
134 return Future.wait(packageVersions.map((id) { 136 return Future.wait(packageVersions.map((id) {
135 if (id.isRoot) return new Future.immediate(id); 137 if (id.isRoot) return new Future.immediate(id);
136 return install(id); 138 return install(id);
137 }).toList()); 139 }).toList());
138 }).then(_saveLockFile) 140 }).then(_saveLockFile)
139 .then(_installSelfReference) 141 .then(_installSelfReference)
140 .then(_linkSecondaryPackageDirs); 142 .then(_linkSecondaryPackageDirs);
141 } 143 }
142 144
143 /// Traverses the root's package dependency graph and loads each of the 145 /// Traverses the root's package dependency graph and loads each of the
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 }); 291 });
290 }).toList()); 292 }).toList());
291 }).then(flatten); 293 }).then(flatten);
292 } 294 }
293 295
294 /// Creates a symlink to the `packages` directory in [dir]. Will replace one 296 /// Creates a symlink to the `packages` directory in [dir]. Will replace one
295 /// if already there. 297 /// if already there.
296 Future _linkSecondaryPackageDir(String dir) { 298 Future _linkSecondaryPackageDir(String dir) {
297 return defer(() { 299 return defer(() {
298 var symlink = path.join(dir, 'packages'); 300 var symlink = path.join(dir, 'packages');
299 return new Future.of(() { 301 if (fileExists(symlink)) {
300 if (fileExists(symlink)) { 302 deleteFile(symlink);
301 deleteFile(symlink); 303 } else if (dirExists(symlink)) {
302 } else if (dirExists(symlink)) { 304 deleteDir(symlink);
303 return deleteDir(symlink); 305 }
304 } 306 return createSymlink(packagesDir, symlink, relative: true);
305 }).then((_) => createSymlink(packagesDir, symlink, relative: true));
306 }); 307 });
307 } 308 }
308 } 309 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/test/utils.dart ('k') | utils/pub/hosted_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698