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

Side by Side Diff: lib/src/source/cached.dart

Issue 2044253003: Refactor Source and SourceRegistry. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Rename LiveSource to BoundSource. Created 4 years, 6 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
« no previous file with comments | « lib/src/source.dart ('k') | lib/src/source/git.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 6
7 import 'package:path/path.dart' as path; 7 import 'package:path/path.dart' as path;
8 8
9 import '../io.dart'; 9 import '../io.dart';
10 import '../package.dart'; 10 import '../package.dart';
11 import '../pubspec.dart'; 11 import '../pubspec.dart';
12 import '../source.dart'; 12 import '../source.dart';
13 import '../utils.dart'; 13 import '../utils.dart';
14 14
15 /// Base class for a [Source] that installs packages into pub's [SystemCache]. 15 /// Base class for a [BoundSource] that installs packages into pub's
16 /// [SystemCache].
16 /// 17 ///
17 /// A source should be cached if it requires network access to retrieve 18 /// A source should be cached if it requires network access to retrieve
18 /// packages or the package needs to be "frozen" at the point in time that it's 19 /// packages or the package needs to be "frozen" at the point in time that it's
19 /// installed. (For example, Git packages are cached because installing from 20 /// installed. (For example, Git packages are cached because installing from
20 /// the same repo over time may yield different commits.) 21 /// the same repo over time may yield different commits.)
21 abstract class CachedSource extends Source { 22 abstract class CachedSource extends BoundSource {
22 /// The root directory of this source's cache within the system cache. 23 /// The root directory of this source's cache within the system cache.
23 /// 24 ///
24 /// This shouldn't be overridden by subclasses. 25 /// This shouldn't be overridden by subclasses.
25 String get systemCacheRoot => path.join(systemCache.rootDir, name); 26 String get systemCacheRoot => path.join(systemCache.rootDir, source.name);
26 27
27 /// If [id] is already in the system cache, just loads it from there. 28 /// If [id] is already in the system cache, just loads it from there.
28 /// 29 ///
29 /// Otherwise, defers to the subclass. 30 /// Otherwise, defers to the subclass.
30 Future<Pubspec> doDescribe(PackageId id) async { 31 Future<Pubspec> doDescribe(PackageId id) async {
31 var packageDir = getDirectory(id); 32 var packageDir = getDirectory(id);
32 if (fileExists(path.join(packageDir, "pubspec.yaml"))) { 33 if (fileExists(path.join(packageDir, "pubspec.yaml"))) {
33 return new Pubspec.load(packageDir, systemCache.sources, 34 return new Pubspec.load(packageDir, systemCache.sources,
34 expectedName: id.name); 35 expectedName: id.name);
35 } 36 }
(...skipping 25 matching lines...) Expand all
61 List<Package> getCachedPackages(); 62 List<Package> getCachedPackages();
62 63
63 /// Reinstalls all packages that have been previously installed into the 64 /// Reinstalls all packages that have been previously installed into the
64 /// system cache by this source. 65 /// system cache by this source.
65 /// 66 ///
66 /// Returns a [Pair] whose first element is the packages that were 67 /// Returns a [Pair] whose first element is the packages that were
67 /// successfully repaired and the second is the packages that failed to be 68 /// successfully repaired and the second is the packages that failed to be
68 /// repaired. 69 /// repaired.
69 Future<Pair<List<PackageId>, List<PackageId>>> repairCachedPackages(); 70 Future<Pair<List<PackageId>, List<PackageId>>> repairCachedPackages();
70 } 71 }
OLDNEW
« no previous file with comments | « lib/src/source.dart ('k') | lib/src/source/git.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698