Index: sdk/lib/_internal/pub_generated/lib/src/source/cached.dart |
diff --git a/sdk/lib/_internal/pub_generated/lib/src/source/cached.dart b/sdk/lib/_internal/pub_generated/lib/src/source/cached.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e3823ea9b03ce7f8ff41a0d9bbb86865264dfc7a |
--- /dev/null |
+++ b/sdk/lib/_internal/pub_generated/lib/src/source/cached.dart |
@@ -0,0 +1,33 @@ |
+library pub.source.cached; |
+import 'dart:async'; |
+import 'package:path/path.dart' as path; |
+import '../io.dart'; |
+import '../package.dart'; |
+import '../pubspec.dart'; |
+import '../source.dart'; |
+import '../utils.dart'; |
+abstract class CachedSource extends Source { |
+ String get systemCacheRoot => path.join(systemCache.rootDir, name); |
+ Future<Pubspec> doDescribe(PackageId id) { |
+ return getDirectory(id).then((packageDir) { |
+ if (fileExists(path.join(packageDir, "pubspec.yaml"))) { |
+ return new Pubspec.load( |
+ packageDir, |
+ systemCache.sources, |
+ expectedName: id.name); |
+ } |
+ return describeUncached(id); |
+ }); |
+ } |
+ Future<Pubspec> describeUncached(PackageId id); |
+ Future get(PackageId id, String symlink) { |
+ return downloadToSystemCache(id).then((pkg) { |
+ createPackageSymlink(id.name, pkg.dir, symlink); |
+ }); |
+ } |
+ Future<bool> isInSystemCache(PackageId id) => |
+ getDirectory(id).then(dirExists); |
+ Future<Package> downloadToSystemCache(PackageId id); |
+ List<Package> getCachedPackages(); |
+ Future<Pair<int, int>> repairCachedPackages(); |
+} |