OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import sys | 5 import sys |
6 | 6 |
7 import schema_util | 7 import schema_util |
8 from docs_server_utils import ToUnicode | 8 from docs_server_utils import ToUnicode |
9 from file_system import FileNotFoundError | 9 from file_system import FileNotFoundError |
10 from future import Future | 10 from future import Future |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 return Future(exc_info=sys.exc_info()) | 200 return Future(exc_info=sys.exc_info()) |
201 | 201 |
202 cache_entry = self._file_object_store.Get(path).Get() | 202 cache_entry = self._file_object_store.Get(path).Get() |
203 if (cache_entry is not None) and (version == cache_entry.version): | 203 if (cache_entry is not None) and (version == cache_entry.version): |
204 return Future(value=cache_entry._cache_data) | 204 return Future(value=cache_entry._cache_data) |
205 | 205 |
206 def compile_(files): | 206 def compile_(files): |
207 cache_data = self._compilation_function(path, files) | 207 cache_data = self._compilation_function(path, files) |
208 self._file_object_store.Set(path, _CacheEntry(cache_data, version)) | 208 self._file_object_store.Set(path, _CacheEntry(cache_data, version)) |
209 return cache_data | 209 return cache_data |
| 210 |
210 return self._file_system.ReadSingle( | 211 return self._file_system.ReadSingle( |
211 path, skip_not_found=skip_not_found).Then(compile_) | 212 path, skip_not_found=skip_not_found).Then(compile_) |
212 | 213 |
213 def GetFromFileListing(self, path): | 214 def GetFromFileListing(self, path): |
214 '''Calls |compilation_function| on the listing of the files at |path|. | 215 '''Calls |compilation_function| on the listing of the files at |path|. |
215 Assumes that the path given is to a directory. | 216 Assumes that the path given is to a directory. |
216 ''' | 217 ''' |
217 AssertIsDirectory(path) | 218 AssertIsDirectory(path) |
218 | 219 |
219 try: | 220 try: |
(...skipping 22 matching lines...) Expand all Loading... |
242 cache_entry = self._list_object_store.Get(path).Get() | 243 cache_entry = self._list_object_store.Get(path).Get() |
243 if cache_entry is not None: | 244 if cache_entry is not None: |
244 return cache_entry.version | 245 return cache_entry.version |
245 return self._file_system.Stat(path).version | 246 return self._file_system.Stat(path).version |
246 | 247 |
247 def FileExists(self, path): | 248 def FileExists(self, path): |
248 return self._file_system.Exists(path) | 249 return self._file_system.Exists(path) |
249 | 250 |
250 def GetIdentity(self): | 251 def GetIdentity(self): |
251 return self._file_system.GetIdentity() | 252 return self._file_system.GetIdentity() |
OLD | NEW |