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

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

Issue 2048933002: Check versions of summaries and cache. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/incremental_cache.dart
diff --git a/pkg/analyzer/lib/src/summary/incremental_cache.dart b/pkg/analyzer/lib/src/summary/incremental_cache.dart
index cadeffb6382fec318d809c46d9d16e38aed74822..111f2eae0b2be8be929cc2e875033a605f2d5d79 100644
--- a/pkg/analyzer/lib/src/summary/incremental_cache.dart
+++ b/pkg/analyzer/lib/src/summary/incremental_cache.dart
@@ -17,6 +17,12 @@ import 'package:convert/convert.dart';
import 'package:crypto/crypto.dart';
/**
+ * The version of the incremental cache. It should be incremented every time
+ * when any cache data structure is changed.
+ */
+const int _VERSION = 1;
+
+/**
* Storage for cache data.
*/
abstract class CacheStorage {
@@ -285,6 +291,7 @@ class IncrementalCache {
ByteConversionSink byteSink = md5.startChunkedConversion(digestSink);
// Add data.
addData(byteSink);
+ byteSink.add(const <int>[_VERSION]);
byteSink.add(configSalt);
// Done.
byteSink.close();
@@ -368,6 +375,10 @@ class IncrementalCache {
return null;
}
bundle = new PackageBundle.fromBuffer(bytes);
+ if (bundle.majorVersion != PackageBundleAssembler.currentMajorVersion ||
+ bundle.minorVersion != PackageBundleAssembler.currentMinorVersion) {
+ return null;
+ }
_bundleMap[key] = bundle;
}
return bundle;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698