Index: utils/pub/hosted_source.dart |
=================================================================== |
--- utils/pub/hosted_source.dart (revision 19938) |
+++ utils/pub/hosted_source.dart (working copy) |
@@ -93,7 +93,7 @@ |
/// from that site. |
Future<String> systemCacheDirectory(PackageId id) { |
var parsed = _parseDescription(id.description); |
- var url = parsed.last.replaceAll(new RegExp(r"^https?://"), ""); |
+ var url = _getSourceDirectory(parsed.last); |
var urlDir = replace(url, new RegExp(r'[<>:"\\/|?*%]'), (match) { |
return '%${match[0].codeUnitAt(0)}'; |
}); |
@@ -118,6 +118,24 @@ |
return description; |
} |
+ Future<List<Package>> getCachedPackages() { |
+ var url = _getSourceDirectory(_defaultUrl); |
+ return listDir(path.join(systemCacheRoot, url)).then((entries) { |
+ return entries.map((entry) { |
+ return new Package.load(null, entry, systemCache.sources); |
Bob Nystrom
2013/03/13 17:44:07
Only indent 2, or better, use => if it fits:
retu
keertip
2013/03/13 18:09:48
Done.
|
+ }); |
+ |
+ }); |
+// var list = new List(); |
+// for (var entry in entries) { |
+// var name = path.basename(entry).replaceAll(new RegExp(r"-(.*)"),""); |
+// var p = new Package.load(null, entry, systemCache.sources); |
+// list.add(p); |
+// } |
+// return list; |
+// }); |
Bob Nystrom
2013/03/13 17:44:07
Remove commented out code. :)
keertip
2013/03/13 18:09:48
Oops! removed!
On 2013/03/13 17:44:07, Bob Nystrom
|
+ } |
+ |
/// When an error occurs trying to read something about [package] from [url], |
/// this tries to translate into a more user friendly error message. Always |
/// throws an error, either the original one or a better one. |
@@ -145,6 +163,10 @@ |
/// The URL of the default package repository. |
final _defaultUrl = "https://pub.dartlang.org"; |
+String _getSourceDirectory(String url){ |
Bob Nystrom
2013/03/13 17:44:07
Space after )
keertip
2013/03/13 18:09:48
Done.
|
+ return url.replaceAll(new RegExp(r"^https?://"), ""); |
+} |
+ |
/// Parses [description] into its server and package name components, then |
/// converts that to a Uri given [pattern]. Ensures the package name is |
/// properly URL encoded. |