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'; |
11 import 'hosted_source.dart'; | 11 import 'hosted_source.dart'; |
12 import 'io.dart'; | 12 import 'io.dart'; |
13 import 'io.dart' as io show createTempDir; | 13 import 'io.dart' as io show createTempDir; |
14 import 'log.dart' as log; | 14 import 'log.dart' as log; |
15 import 'package.dart'; | 15 import 'package.dart'; |
| 16 import 'path_source.dart'; |
16 import 'pubspec.dart'; | 17 import 'pubspec.dart'; |
17 import 'sdk_source.dart'; | 18 import 'sdk_source.dart'; |
18 import 'source.dart'; | 19 import 'source.dart'; |
19 import 'source_registry.dart'; | 20 import 'source_registry.dart'; |
20 import 'utils.dart'; | 21 import 'utils.dart'; |
21 import 'version.dart'; | 22 import 'version.dart'; |
22 | 23 |
23 /// The system-wide cache of installed packages. | 24 /// The system-wide cache of installed packages. |
24 /// | 25 /// |
25 /// This cache contains all packages that are downloaded from the internet. | 26 /// This cache contains all packages that are downloaded from the internet. |
(...skipping 13 matching lines...) Expand all Loading... |
39 | 40 |
40 /// Creates a new package cache which is backed by the given directory on the | 41 /// Creates a new package cache which is backed by the given directory on the |
41 /// user's file system. | 42 /// user's file system. |
42 SystemCache(this.rootDir) | 43 SystemCache(this.rootDir) |
43 : _pendingInstalls = new Map<PackageId, Future<Package>>(), | 44 : _pendingInstalls = new Map<PackageId, Future<Package>>(), |
44 sources = new SourceRegistry(); | 45 sources = new SourceRegistry(); |
45 | 46 |
46 /// Creates a system cache and registers the standard set of sources. | 47 /// Creates a system cache and registers the standard set of sources. |
47 factory SystemCache.withSources(String rootDir) { | 48 factory SystemCache.withSources(String rootDir) { |
48 var cache = new SystemCache(rootDir); | 49 var cache = new SystemCache(rootDir); |
49 cache.register(new SdkSource()); | |
50 cache.register(new GitSource()); | 50 cache.register(new GitSource()); |
51 cache.register(new HostedSource()); | 51 cache.register(new HostedSource()); |
| 52 cache.register(new PathSource()); |
| 53 cache.register(new SdkSource()); |
52 cache.sources.setDefault('hosted'); | 54 cache.sources.setDefault('hosted'); |
53 return cache; | 55 return cache; |
54 } | 56 } |
55 | 57 |
56 /// Registers a new source. This source must not have the same name as a | 58 /// Registers a new source. This source must not have the same name as a |
57 /// source that's already been registered. | 59 /// source that's already been registered. |
58 void register(Source source) { | 60 void register(Source source) { |
59 source.bind(this); | 61 source.bind(this); |
60 sources.register(source); | 62 sources.register(source); |
61 } | 63 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 110 |
109 /// Delete's the system cache's internal temp directory. | 111 /// Delete's the system cache's internal temp directory. |
110 Future deleteTempDir() { | 112 Future deleteTempDir() { |
111 log.fine('Clean up system cache temp directory $tempDir.'); | 113 log.fine('Clean up system cache temp directory $tempDir.'); |
112 return defer(() { | 114 return defer(() { |
113 if (!dirExists(tempDir)) return; | 115 if (!dirExists(tempDir)) return; |
114 return deleteDir(tempDir); | 116 return deleteDir(tempDir); |
115 }); | 117 }); |
116 } | 118 } |
117 } | 119 } |
OLD | NEW |