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

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

Issue 10941049: Remove "pub list" command. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove dead code. Created 8 years, 3 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 | « utils/pub/pub.dart ('k') | utils/tests/pub/pub_test.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('system_cache'); 5 #library('system_cache');
6 6
7 #import('io.dart'); 7 #import('io.dart');
8 #import('package.dart'); 8 #import('package.dart');
9 #import('source.dart'); 9 #import('source.dart');
10 #import('source_registry.dart'); 10 #import('source_registry.dart');
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 /** 44 /**
45 * Registers a new source. This source must not have the same name as a source 45 * Registers a new source. This source must not have the same name as a source
46 * that's already been registered. 46 * that's already been registered.
47 */ 47 */
48 void register(Source source) { 48 void register(Source source) {
49 source.bind(this); 49 source.bind(this);
50 sources.register(source); 50 sources.register(source);
51 } 51 }
52 52
53 /** 53 /**
54 * Loads all of the package ids in the cache and returns them.
55 */
56 Future<List<PackageId>> listAll() {
57 return listDir(rootDir).chain((paths) {
58 final sources = paths.map((path) {
59 final source = sources[basename(path)];
60 return listDir(path).transform((subpaths) {
61 // TODO(rnystrom): Once there are cached packages and this path is
62 // being used, figure out how version numbers should be acquired.
63 return subpaths.map((subpath) =>
64 new PackageId(
65 basename(subpath), source, Version.none, basename(subpath)));
66 });
67 });
68 return Futures.wait(sources).transform(flatten);
69 });
70 }
71
72 /**
73 * Ensures that the package identified by [id] is installed to the cache, 54 * Ensures that the package identified by [id] is installed to the cache,
74 * loads it, and returns it. 55 * loads it, and returns it.
75 * 56 *
76 * It is an error to try installing a package from a source with `shouldCache 57 * It is an error to try installing a package from a source with `shouldCache
77 * == false` to the system cache. 58 * == false` to the system cache.
78 */ 59 */
79 Future<Package> install(PackageId id) { 60 Future<Package> install(PackageId id) {
80 if (!id.source.shouldCache) { 61 if (!id.source.shouldCache) {
81 throw new IllegalArgumentException("Package $id is not cacheable."); 62 throw new IllegalArgumentException("Package $id is not cacheable.");
82 } 63 }
83 64
84 var pending = _pendingInstalls[id]; 65 var pending = _pendingInstalls[id];
85 if (pending != null) return pending; 66 if (pending != null) return pending;
86 67
87 var future = id.source.installToSystemCache(id); 68 var future = id.source.installToSystemCache(id);
88 always(future, () => _pendingInstalls.remove(id)); 69 always(future, () => _pendingInstalls.remove(id));
89 _pendingInstalls[id] = future; 70 _pendingInstalls[id] = future;
90 return future; 71 return future;
91 } 72 }
92 } 73 }
OLDNEW
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/tests/pub/pub_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698