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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:io' as io; | 6 import 'dart:io' as io; |
7 import "dart:convert"; | 7 import "dart:convert"; |
8 | 8 |
9 import 'package:http/http.dart' as http; | 9 import 'package:http/http.dart' as http; |
10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 "$systemCacheRoot/${_urlToDirectory(server)}"); | 264 "$systemCacheRoot/${_urlToDirectory(server)}"); |
265 | 265 |
266 var dir = path.join(systemCacheRoot, _urlToDirectory(server)); | 266 var dir = path.join(systemCacheRoot, _urlToDirectory(server)); |
267 | 267 |
268 var versions; | 268 var versions; |
269 if (dirExists(dir)) { | 269 if (dirExists(dir)) { |
270 versions = await listDir(dir).map((entry) { | 270 versions = await listDir(dir).map((entry) { |
271 var components = path.basename(entry).split("-"); | 271 var components = path.basename(entry).split("-"); |
272 if (components.first != ref.name) return null; | 272 if (components.first != ref.name) return null; |
273 return HostedSource.idFor( | 273 return HostedSource.idFor( |
274 ref.name, new Version.parse(components.last), | 274 ref.name, new Version.parse(components.skip(1).join("-")), |
275 url: _serverFor(ref.description)); | 275 url: _serverFor(ref.description)); |
276 }).where((id) => id != null).toList(); | 276 }).where((id) => id != null).toList(); |
277 } else { | 277 } else { |
278 versions = []; | 278 versions = []; |
279 } | 279 } |
280 | 280 |
281 // If there are no versions in the cache, report a clearer error. | 281 // If there are no versions in the cache, report a clearer error. |
282 if (versions.isEmpty) { | 282 if (versions.isEmpty) { |
283 throw new PackageNotFoundException( | 283 throw new PackageNotFoundException( |
284 "Could not find package ${ref.name} in cache."); | 284 "Could not find package ${ref.name} in cache."); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 var name = description["name"]; | 393 var name = description["name"]; |
394 if (name is! String) { | 394 if (name is! String) { |
395 throw new FormatException("The 'name' key must have a string value."); | 395 throw new FormatException("The 'name' key must have a string value."); |
396 } | 396 } |
397 | 397 |
398 var url = description["url"]; | 398 var url = description["url"]; |
399 if (url == null) url = HostedSource.defaultUrl; | 399 if (url == null) url = HostedSource.defaultUrl; |
400 | 400 |
401 return new Pair<String, String>(name, url); | 401 return new Pair<String, String>(name, url); |
402 } | 402 } |
OLD | NEW |