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

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

Issue 10736015: Make the Git source install to the system cache. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor fixes Created 8 years, 5 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
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 * == false` to the system cache. 75 * == false` to the system cache.
76 */ 76 */
77 Future<Package> install(PackageId id) { 77 Future<Package> install(PackageId id) {
78 if (!id.source.shouldCache) { 78 if (!id.source.shouldCache) {
79 throw new IllegalArgumentException("Package $id is not cacheable."); 79 throw new IllegalArgumentException("Package $id is not cacheable.");
80 } 80 }
81 81
82 var pending = _pendingInstalls[id]; 82 var pending = _pendingInstalls[id];
83 if (pending != null) return pending; 83 if (pending != null) return pending;
84 84
85 var path = id.source.systemCacheDirectory(id); 85 var future = id.source.installToSystemCache(id);
86 var future = exists(path).chain((exists) {
87 // TODO(nweiz): better error handling
88 if (exists) throw 'Package $id is already installed.';
89 return ensureDir(dirname(path));
90 }).chain((_) {
91 return id.source.install(id, path);
92 }).chain((found) {
93 if (!found) throw 'Package $id not found.';
94 return Package.load(path, sources);
95 });
96
97 always(future, () => _pendingInstalls.remove(id)); 86 always(future, () => _pendingInstalls.remove(id));
98 _pendingInstalls[id] = future; 87 _pendingInstalls[id] = future;
99 return future; 88 return future;
100 } 89 }
101 } 90 }
OLDNEW
« utils/pub/git_source.dart ('K') | « utils/pub/source.dart ('k') | utils/pub/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698