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

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

Issue 12171002: Tweak SDK constraint checking a bit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
« utils/pub/git_source.dart ('K') | « utils/pub/git_source.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 '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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 /// Registers a new source. This source must not have the same name as a 56 /// Registers a new source. This source must not have the same name as a
57 /// source that's already been registered. 57 /// source that's already been registered.
58 void register(Source source) { 58 void register(Source source) {
59 source.bind(this); 59 source.bind(this);
60 sources.register(source); 60 sources.register(source);
61 } 61 }
62 62
63 /// Gets the package identified by [id]. If the package is already cached, 63 /// Gets the package identified by [id]. If the package is already cached,
64 /// reads it from the cache. Otherwise, requests it from the source. 64 /// reads it from the cache. Otherwise, requests it from the source.
65 Future<Package> describe(PackageId id) { 65 Future<Pubspec> describe(PackageId id) {
66 Future<Package> getUncached() { 66 Future<Pubspec> getUncached() {
nweiz 2013/02/02 00:15:29 This probably doesn't need to be a separate functi
Bob Nystrom 2013/02/02 00:47:10 Done.
67 // Not cached, so get it from the source. 67 // Not cached, so get it from the source.
68 return id.describe().then((pubspec) => new Package.inMemory(pubspec)); 68 return id.describe();
69 } 69 }
70 70
71 // Try to get it from the system cache first. 71 // Try to get it from the system cache first.
72 if (id.source.shouldCache) { 72 if (id.source.shouldCache) {
73 return id.systemCacheDirectory.then((packageDir) { 73 return id.systemCacheDirectory.then((packageDir) {
74 if (!dirExistsSync(packageDir)) return getUncached(); 74 if (!dirExistsSync(packageDir)) return getUncached();
75 return Package.load(id.name, packageDir, sources); 75 // TODO(rnystrom): Going through Package for this is a bit weird.
76 // Once Package loading is synchronous, should give Pubspec itself a
77 // constructor that loads the file.
78 return Package.load(id.name, packageDir, sources)
79 .then((package) => package.pubspec);;
nweiz 2013/02/02 00:15:29 Style nit: extra semicolon
Bob Nystrom 2013/02/02 00:47:10 Done.
76 }); 80 });
77 } 81 }
78 82
79 // Not cached, so get it from the source. 83 // Not cached, so get it from the source.
80 return getUncached(); 84 return getUncached();
81 } 85 }
82 86
83 /// Ensures that the package identified by [id] is installed to the cache, 87 /// Ensures that the package identified by [id] is installed to the cache,
84 /// loads it, and returns it. 88 /// loads it, and returns it.
85 /// 89 ///
(...skipping 26 matching lines...) Expand all
112 116
113 /// Delete's the system cache's internal temp directory. 117 /// Delete's the system cache's internal temp directory.
114 Future deleteTempDir() { 118 Future deleteTempDir() {
115 log.fine('Clean up system cache temp directory $tempDir.'); 119 log.fine('Clean up system cache temp directory $tempDir.');
116 return dirExists(tempDir).then((exists) { 120 return dirExists(tempDir).then((exists) {
117 if (!exists) return; 121 if (!exists) return;
118 return deleteDir(tempDir); 122 return deleteDir(tempDir);
119 }); 123 });
120 } 124 }
121 } 125 }
OLDNEW
« utils/pub/git_source.dart ('K') | « utils/pub/git_source.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698