| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library source.caching_pub_package_map_provider; | 5 library source.caching_pub_package_map_provider; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'dart:core'; | 8 import 'dart:core'; |
| 9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
| 10 | 10 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 int runCount = 0; | 121 int runCount = 0; |
| 122 PackageMapInfo info; | 122 PackageMapInfo info; |
| 123 while (true) { | 123 while (true) { |
| 124 // Capture the current time so that we can tell if an input file | 124 // Capture the current time so that we can tell if an input file |
| 125 // has changed while running pub list. This is done | 125 // has changed while running pub list. This is done |
| 126 // by writing to a file rather than getting millisecondsSinceEpoch | 126 // by writing to a file rather than getting millisecondsSinceEpoch |
| 127 // because file modification time has different granularity | 127 // because file modification time has different granularity |
| 128 // on diferent systems. | 128 // on different systems. |
| 129 int startStamp; | 129 int startStamp; |
| 130 try { | 130 try { |
| 131 startStamp = _writeFile(_touchFile, 'touch'); | 131 startStamp = _writeFile(_touchFile, 'touch'); |
| 132 } catch (exception, stackTrace) { | 132 } catch (exception, stackTrace) { |
| 133 AnalysisEngine.instance.logger.logInformation( | 133 AnalysisEngine.instance.logger.logInformation( |
| 134 'Exception writing $_touchFile\n$exception\n$stackTrace'); | 134 'Exception writing $_touchFile\n$exception\n$stackTrace'); |
| 135 startStamp = new DateTime.now().millisecondsSinceEpoch; | 135 startStamp = new DateTime.now().millisecondsSinceEpoch; |
| 136 } | 136 } |
| 137 // computePackageMap calls parsePackageMap which caches the result | 137 // computePackageMap calls parsePackageMap which caches the result |
| 138 info = super.computePackageMap(folder); | 138 info = super.computePackageMap(folder); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // TODO(danrubel) This implementation assumes that | 251 // TODO(danrubel) This implementation assumes that |
| 252 // two separate processes are not accessing the cache file at the same time | 252 // two separate processes are not accessing the cache file at the same time |
| 253 io.File file = new io.File(cacheFile.path); | 253 io.File file = new io.File(cacheFile.path); |
| 254 if (!file.parent.existsSync()) { | 254 if (!file.parent.existsSync()) { |
| 255 file.parent.createSync(recursive: true); | 255 file.parent.createSync(recursive: true); |
| 256 } | 256 } |
| 257 file.writeAsStringSync(content, flush: true); | 257 file.writeAsStringSync(content, flush: true); |
| 258 return file.lastModifiedSync().millisecondsSinceEpoch; | 258 return file.lastModifiedSync().millisecondsSinceEpoch; |
| 259 } | 259 } |
| 260 } | 260 } |
| OLD | NEW |