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

Side by Side Diff: chrome/common/extensions/docs/server2/compiled_file_system.py

Issue 429723005: Docserver: Only fetch content versions in the crons, not their contents. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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 unified diff | Download patch
OLDNEW
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 cache_entry = self._list_object_store.Get(path).Get() 225 cache_entry = self._list_object_store.Get(path).Get()
226 if (cache_entry is not None) and (version == cache_entry.version): 226 if (cache_entry is not None) and (version == cache_entry.version):
227 return Future(value=cache_entry._cache_data) 227 return Future(value=cache_entry._cache_data)
228 228
229 def next(files): 229 def next(files):
230 cache_data = self._compilation_function(path, files) 230 cache_data = self._compilation_function(path, files)
231 self._list_object_store.Set(path, _CacheEntry(cache_data, version)) 231 self._list_object_store.Set(path, _CacheEntry(cache_data, version))
232 return cache_data 232 return cache_data
233 return self._RecursiveList(path).Then(next) 233 return self._RecursiveList(path).Then(next)
234 234
235 def GetFileVersion(self, path): 235 # _GetFileVersionFromCache and _GetFileListingVersionFromCache are exposed
236 # *only* so that ChainedCompiledFileSystem can optimise its caches. *Do not*
237 # use these methods otherwise, they don't do what you want. Use
238 # FileSystem.Stat on the FileSystem that this CompiledFileSystem uses.
239
240 def _GetFileVersionFromCache(self, path):
236 cache_entry = self._file_object_store.Get(path).Get() 241 cache_entry = self._file_object_store.Get(path).Get()
237 if cache_entry is not None: 242 if cache_entry is not None:
238 return cache_entry.version 243 return Future(value=cache_entry.version)
239 return self._file_system.Stat(path).version 244 stat_future = self._file_system.StatAsync(path)
245 return Future(callback=lambda: stat_future.Get().version)
240 246
241 def GetFileListingVersion(self, path): 247 def _GetFileListingVersionFromCache(self, path):
242 path = ToDirectory(path) 248 path = ToDirectory(path)
243 cache_entry = self._list_object_store.Get(path).Get() 249 cache_entry = self._list_object_store.Get(path).Get()
244 if cache_entry is not None: 250 if cache_entry is not None:
245 return cache_entry.version 251 return Future(value=cache_entry.version)
246 return self._file_system.Stat(path).version 252 stat_future = self._file_system.StatAsync(path)
247 253 return Future(callback=lambda: stat_future.Get().version)
248 def FileExists(self, path):
249 return self._file_system.Exists(path)
250 254
251 def GetIdentity(self): 255 def GetIdentity(self):
252 return self._file_system.GetIdentity() 256 return self._file_system.GetIdentity()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698