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

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

Issue 474293007: Docserver: Automatically implement FileSystem.Stat if FileSystem.StatAsync has (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/file_system.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 posixpath 5 import posixpath
6 import sys 6 import sys
7 7
8 from file_system import FileSystem, StatInfo, FileNotFoundError 8 from file_system import FileSystem, StatInfo, FileNotFoundError
9 from future import Future 9 from future import Future
10 from path_util import IsDirectory, ToDirectory 10 from path_util import IsDirectory, ToDirectory
(...skipping 15 matching lines...) Expand all
26 self._stat_object_store = create_object_store('stat') 26 self._stat_object_store = create_object_store('stat')
27 # The read caches can start populated (start_empty=False) because file 27 # The read caches can start populated (start_empty=False) because file
28 # updates are picked up by the stat, so it doesn't need the force-refresh 28 # updates are picked up by the stat, so it doesn't need the force-refresh
29 # which starting empty is designed for. Without this optimisation, cron 29 # which starting empty is designed for. Without this optimisation, cron
30 # runs are extra slow. 30 # runs are extra slow.
31 self._read_object_store = create_object_store('read', start_empty=False) 31 self._read_object_store = create_object_store('read', start_empty=False)
32 32
33 def Refresh(self): 33 def Refresh(self):
34 return self._file_system.Refresh() 34 return self._file_system.Refresh()
35 35
36 def Stat(self, path):
37 return self.StatAsync(path).Get()
38
39 def StatAsync(self, path): 36 def StatAsync(self, path):
40 '''Stats the directory given, or if a file is given, stats the file's parent 37 '''Stats the directory given, or if a file is given, stats the file's parent
41 directory to get info about the file. 38 directory to get info about the file.
42 ''' 39 '''
43 # Always stat the parent directory, since it will have the stat of the child 40 # Always stat the parent directory, since it will have the stat of the child
44 # anyway, and this gives us an entire directory's stat info at once. 41 # anyway, and this gives us an entire directory's stat info at once.
45 dir_path, file_path = posixpath.split(path) 42 dir_path, file_path = posixpath.split(path)
46 dir_path = ToDirectory(dir_path) 43 dir_path = ToDirectory(dir_path)
47 44
48 def make_stat_info(dir_stat): 45 def make_stat_info(dir_stat):
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return new_results 122 return new_results
126 # Read in the values that were uncached or old. 123 # Read in the values that were uncached or old.
127 return self._file_system.Read(set(paths) - set(fresh_data.iterkeys()), 124 return self._file_system.Read(set(paths) - set(fresh_data.iterkeys()),
128 skip_not_found=skip_not_found).Then(next) 125 skip_not_found=skip_not_found).Then(next)
129 126
130 def GetIdentity(self): 127 def GetIdentity(self):
131 return self._file_system.GetIdentity() 128 return self._file_system.GetIdentity()
132 129
133 def __repr__(self): 130 def __repr__(self):
134 return '%s of <%s>' % (type(self).__name__, repr(self._file_system)) 131 return '%s of <%s>' % (type(self).__name__, repr(self._file_system))
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/file_system.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698