| 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 library system_cache; | 5 library system_cache; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 | 9 |
| 10 import 'git_source.dart'; | 10 import 'git_source.dart'; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 /// The sources from which to install packages. | 36 /// The sources from which to install packages. |
| 37 final SourceRegistry sources; | 37 final SourceRegistry sources; |
| 38 | 38 |
| 39 /// Creates a new package cache which is backed by the given directory on the | 39 /// Creates a new package cache which is backed by the given directory on the |
| 40 /// user's file system. | 40 /// user's file system. |
| 41 SystemCache(this.rootDir) | 41 SystemCache(this.rootDir) |
| 42 : _pendingInstalls = new Map<PackageId, Future<Package>>(), | 42 : _pendingInstalls = new Map<PackageId, Future<Package>>(), |
| 43 sources = new SourceRegistry(); | 43 sources = new SourceRegistry(); |
| 44 | 44 |
| 45 /// Creates a system cache and registers the standard set of sources. | 45 /// Creates a system cache and registers the standard set of sources. |
| 46 factory SystemCache.withSources(String rootDir, String sdkDir) { | 46 factory SystemCache.withSources(String rootDir) { |
| 47 var cache = new SystemCache(rootDir); | 47 var cache = new SystemCache(rootDir); |
| 48 cache.register(new SdkSource(sdkDir)); | 48 cache.register(new SdkSource()); |
| 49 cache.register(new GitSource()); | 49 cache.register(new GitSource()); |
| 50 cache.register(new HostedSource()); | 50 cache.register(new HostedSource()); |
| 51 cache.sources.setDefault('hosted'); | 51 cache.sources.setDefault('hosted'); |
| 52 return cache; | 52 return cache; |
| 53 } | 53 } |
| 54 | 54 |
| 55 /// Registers a new source. This source must not have the same name as a | 55 /// Registers a new source. This source must not have the same name as a |
| 56 /// source that's already been registered. | 56 /// source that's already been registered. |
| 57 void register(Source source) { | 57 void register(Source source) { |
| 58 source.bind(this); | 58 source.bind(this); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 /// Delete's the system cache's internal temp directory. | 92 /// Delete's the system cache's internal temp directory. |
| 93 Future deleteTempDir() { | 93 Future deleteTempDir() { |
| 94 log.fine('Clean up system cache temp directory $tempDir.'); | 94 log.fine('Clean up system cache temp directory $tempDir.'); |
| 95 return dirExists(tempDir).then((exists) { | 95 return dirExists(tempDir).then((exists) { |
| 96 if (!exists) return new Future.immediate(null); | 96 if (!exists) return new Future.immediate(null); |
| 97 return deleteDir(tempDir); | 97 return deleteDir(tempDir); |
| 98 }); | 98 }); |
| 99 } | 99 } |
| 100 } | 100 } |
| OLD | NEW |