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

Unified Diff: pkg/analyzer/lib/src/summary/pub_summary.dart

Issue 2328613002: Verify that cache unlinked and linked bundles are majorVersion compatible. (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/pub_summary_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/pub_summary.dart
diff --git a/pkg/analyzer/lib/src/summary/pub_summary.dart b/pkg/analyzer/lib/src/summary/pub_summary.dart
index ed7221a3bd6ee43d410c962e0b5a1cce3ca3383b..e77ca7e469fe6f364f0f22eab831c3e717ecb8f4 100644
--- a/pkg/analyzer/lib/src/summary/pub_summary.dart
+++ b/pkg/analyzer/lib/src/summary/pub_summary.dart
@@ -80,6 +80,12 @@ class PubSummaryManager {
static const UNLINKED_NAME = 'unlinked.ds';
static const UNLINKED_SPEC_NAME = 'unlinked_spec.ds';
+ /**
+ * See [PackageBundleAssembler.currentMajorVersion].
+ */
+ @visibleForTesting
+ int majorVersion = PackageBundleAssembler.currentMajorVersion;
Brian Wilkerson 2016/09/08 16:42:28 Should this be final?
scheglov 2016/09/08 16:44:24 No. The only reason it was added is to be able to
Paul Berry 2016/09/08 16:45:16 I was just about to make a similar comment. I'd p
scheglov 2016/09/08 17:02:37 OK, it seems that we have a consensus here :-) Don
+
final ResourceProvider resourceProvider;
/**
@@ -342,7 +348,9 @@ class PubSummaryManager {
try {
addDartFiles(libFolder);
- List<int> bytes = assembler.assemble().toBuffer();
+ PackageBundleBuilder bundleWriter = assembler.assemble();
+ bundleWriter.majorVersion = majorVersion;
+ List<int> bytes = bundleWriter.toBuffer();
String fileName = _getUnlinkedName(strong);
_writeAtomic(package.folder, fileName, bytes);
} on FileSystemException {
@@ -382,27 +390,36 @@ class PubSummaryManager {
if (bundle != null) {
return bundle;
}
+
// Try to read from the file system.
String fileName = _getUnlinkedName(strong);
- File unlinkedFile = package.folder.getChildAssumingFile(fileName);
- if (unlinkedFile.exists) {
+ File file = package.folder.getChildAssumingFile(fileName);
+ if (file.exists) {
try {
- List<int> bytes = unlinkedFile.readAsBytesSync();
+ List<int> bytes = file.readAsBytesSync();
bundle = new PackageBundle.fromBuffer(bytes);
- unlinkedBundleMap[package] = bundle;
- // TODO(scheglov) if not in the pub cache, check for consistency
- return bundle;
} on FileSystemException {
// Ignore file system exceptions.
}
}
+
+ bool isInPubCache = isPathInPubCache(pathContext, package.folder.path);
+
+ // Verify compatibility.
+ // TODO(scheglov) if not in the pub cache, check for consistency
+ if (bundle != null && bundle.majorVersion == majorVersion) {
+ unlinkedBundleMap[package] = bundle;
+ return bundle;
+ }
+
// Schedule computation in the background, if in the pub cache.
- if (isPathInPubCache(pathContext, package.folder.path)) {
+ if (isInPubCache) {
if (seenPackages.add(package)) {
_scheduleUnlinked(package);
}
}
- // The bundle is for available.
+
+ // The bundle is not available.
return null;
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/pub_summary_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698