| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 cache_entry = self._list_object_store.Get(path).Get() | 222 cache_entry = self._list_object_store.Get(path).Get() |
| 223 if (cache_entry is not None) and (version == cache_entry.version): | 223 if (cache_entry is not None) and (version == cache_entry.version): |
| 224 return Future(value=cache_entry._cache_data) | 224 return Future(value=cache_entry._cache_data) |
| 225 | 225 |
| 226 def next(files): | 226 def next(files): |
| 227 cache_data = self._compilation_function(path, files) | 227 cache_data = self._compilation_function(path, files) |
| 228 self._list_object_store.Set(path, _CacheEntry(cache_data, version)) | 228 self._list_object_store.Set(path, _CacheEntry(cache_data, version)) |
| 229 return cache_data | 229 return cache_data |
| 230 return self._RecursiveList(path).Then(next) | 230 return self._RecursiveList(path).Then(next) |
| 231 | 231 |
| 232 def GetFileVersion(self, path): | 232 # _GetFileVersionFromCache and _GetFileListingVersionFromCache are exposed |
| 233 # *only* so that ChainedCompiledFileSystem can optimise its caches. *Do not* |
| 234 # use these methods otherwise, they don't do what you want. Use |
| 235 # FileSystem.Stat on the FileSystem that this CompiledFileSystem uses. |
| 236 |
| 237 def _GetFileVersionFromCache(self, path): |
| 233 cache_entry = self._file_object_store.Get(path).Get() | 238 cache_entry = self._file_object_store.Get(path).Get() |
| 234 if cache_entry is not None: | 239 if cache_entry is not None: |
| 235 return cache_entry.version | 240 return Future(value=cache_entry.version) |
| 236 return self._file_system.Stat(path).version | 241 stat_future = self._file_system.StatAsync(path) |
| 242 return Future(callback=lambda: stat_future.Get().version) |
| 237 | 243 |
| 238 def GetFileListingVersion(self, path): | 244 def _GetFileListingVersionFromCache(self, path): |
| 239 path = ToDirectory(path) | 245 path = ToDirectory(path) |
| 240 cache_entry = self._list_object_store.Get(path).Get() | 246 cache_entry = self._list_object_store.Get(path).Get() |
| 241 if cache_entry is not None: | 247 if cache_entry is not None: |
| 242 return cache_entry.version | 248 return Future(value=cache_entry.version) |
| 243 return self._file_system.Stat(path).version | 249 stat_future = self._file_system.StatAsync(path) |
| 244 | 250 return Future(callback=lambda: stat_future.Get().version) |
| 245 def FileExists(self, path): | |
| 246 return self._file_system.Exists(path) | |
| 247 | 251 |
| 248 def GetIdentity(self): | 252 def GetIdentity(self): |
| 249 return self._file_system.GetIdentity() | 253 return self._file_system.GetIdentity() |
| OLD | NEW |