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

Unified Diff: pkg/analyzer_cli/lib/src/driver.dart

Issue 2697653004: If the state location is not accessible, use MemoryByteStore. (Closed)
Patch Set: Created 3 years, 10 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 | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/lib/src/driver.dart
diff --git a/pkg/analyzer_cli/lib/src/driver.dart b/pkg/analyzer_cli/lib/src/driver.dart
index 0c4f86d073d665ab0213fd718a289a4aa57a6366..f3c57a2ae99c0a6f00728150a8dd329cfffa696c 100644
--- a/pkg/analyzer_cli/lib/src/driver.dart
+++ b/pkg/analyzer_cli/lib/src/driver.dart
@@ -78,13 +78,7 @@ class Driver implements CommandLineStarter {
new PerformanceTag("Driver._analyzeAll");
static ByteStore analysisDriverMemoryByteStore = new MemoryByteStore();
- static ByteStore analysisDriverFileByteStore = new MemoryCachingByteStore(
- new EvictingFileByteStore(
- PhysicalResourceProvider.INSTANCE
- .getStateLocation('.analysis-driver')
- .path,
- 1024 * 1024 * 1024 /*1 GiB*/),
- 64 * 1024 * 1024 /*64 MiB*/);
+ static ByteStore analysisDriverFileByteStore = _createFileByteStore();
/// The plugins that are defined outside the `analyzer_cli` package.
List<Plugin> _userDefinedPlugins = <Plugin>[];
@@ -794,6 +788,22 @@ class Driver implements CommandLineStarter {
context.analysisOptions = analysisOptions;
}
+ /**
+ * If the state location can be accessed, return the file byte store,
+ * otherwise return the memory byte store.
+ */
+ static ByteStore _createFileByteStore() {
+ const int M = 1024 * 1024 /*1 MiB*/;
+ const int G = 1024 * 1024 * 1024 /*1 GiB*/;
+ file_system.Folder stateLocation =
+ PhysicalResourceProvider.INSTANCE.getStateLocation('.analysis-driver');
+ if (stateLocation == null) {
+ return new MemoryByteStore();
+ }
+ return new MemoryCachingByteStore(
+ new EvictingFileByteStore(stateLocation.path, G), 64 * M);
+ }
+
/// Perform a deep comparison of two string lists.
static bool _equalLists(List<String> l1, List<String> l2) {
if (l1.length != l2.length) {
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698