| Index: utils/pub/system_cache.dart
|
| diff --git a/utils/pub/system_cache.dart b/utils/pub/system_cache.dart
|
| index fd9035417ebe4c31d0d3fc26370dca3735c332b8..8065f9a16606650b5a7f347205fc89fa8e27d3e6 100644
|
| --- a/utils/pub/system_cache.dart
|
| +++ b/utils/pub/system_cache.dart
|
| @@ -82,7 +82,18 @@ class SystemCache {
|
| var pending = _pendingInstalls[id];
|
| if (pending != null) return pending;
|
|
|
| - var future = id.source.installToSystemCache(id);
|
| + var path = id.source.systemCacheDirectory(id);
|
| + var future = exists(path).chain((exists) {
|
| + // TODO(nweiz): better error handling
|
| + if (exists) throw 'Package $id is already installed.';
|
| + return ensureDir(dirname(path));
|
| + }).chain((_) {
|
| + return id.source.install(id, path);
|
| + }).chain((found) {
|
| + if (!found) throw 'Package $id not found.';
|
| + return Package.load(path, sources);
|
| + });
|
| +
|
| always(future, () => _pendingInstalls.remove(id));
|
| _pendingInstalls[id] = future;
|
| return future;
|
|
|