| OLD | NEW |
| 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 /** | 5 /** |
| 6 * The system-wide cache of installed packages. | 6 * The system-wide cache of installed packages. |
| 7 * | 7 * |
| 8 * This cache contains all packages that are downloaded from the internet. | 8 * This cache contains all packages that are downloaded from the internet. |
| 9 * Packages that are available locally (e.g. from the SDK) don't use this cache. | 9 * Packages that are available locally (e.g. from the SDK) don't use this cache. |
| 10 */ | 10 */ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 sources = new SourceRegistry(); | 33 sources = new SourceRegistry(); |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Loads all of the package ids in the cache and returns them. | 36 * Loads all of the package ids in the cache and returns them. |
| 37 */ | 37 */ |
| 38 Future<List<PackageId>> listAll() { | 38 Future<List<PackageId>> listAll() { |
| 39 return listDir(rootDir).chain((paths) { | 39 return listDir(rootDir).chain((paths) { |
| 40 final sources = paths.map((path) { | 40 final sources = paths.map((path) { |
| 41 final source = sources[basename(path)]; | 41 final source = sources[basename(path)]; |
| 42 return listDir(path).transform((subpaths) { | 42 return listDir(path).transform((subpaths) { |
| 43 // TODO(rnystrom): Once there are cached packages and this path is |
| 44 // being used, figure out how version numbers should be acquired. |
| 43 return subpaths.map((subpath) => | 45 return subpaths.map((subpath) => |
| 44 new PackageId(basename(subpath), source)); | 46 new PackageId(basename(subpath), source, Version.none)); |
| 45 }); | 47 }); |
| 46 }); | 48 }); |
| 47 return Futures.wait(sources).transform(flatten); | 49 return Futures.wait(sources).transform(flatten); |
| 48 }); | 50 }); |
| 49 } | 51 } |
| 50 | 52 |
| 51 /** | 53 /** |
| 52 * 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, |
| 53 * loads it, and returns it. | 55 * loads it, and returns it. |
| 54 * | 56 * |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 throw 'Package ${id.fullName} not found in source "${id.source.name}".'; | 77 throw 'Package ${id.fullName} not found in source "${id.source.name}".'; |
| 76 } | 78 } |
| 77 return Package.load(path, sources); | 79 return Package.load(path, sources); |
| 78 }); | 80 }); |
| 79 | 81 |
| 80 always(future, () => _pendingInstalls.remove(id)); | 82 always(future, () => _pendingInstalls.remove(id)); |
| 81 _pendingInstalls[id] = future; | 83 _pendingInstalls[id] = future; |
| 82 return future; | 84 return future; |
| 83 } | 85 } |
| 84 } | 86 } |
| OLD | NEW |