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

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

Issue 660383002: Docserver: Persist stat cache for versioned file systems (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: all the things Created 6 years, 1 month 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 posixpath 5 import posixpath
6 import traceback 6 import traceback
7 7
8 from future import Future 8 from future import Future
9 from path_util import ( 9 from path_util import (
10 AssertIsDirectory, AssertIsValid, IsDirectory, IsValid, SplitParent, 10 AssertIsDirectory, AssertIsValid, IsDirectory, IsValid, SplitParent,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 raw StatInfo. 153 raw StatInfo.
154 154
155 This is a bandaid for a lack of an async Stat function. Stat() should be 155 This is a bandaid for a lack of an async Stat function. Stat() should be
156 async by default but for now just let implementations override this if they 156 async by default but for now just let implementations override this if they
157 like. 157 like.
158 ''' 158 '''
159 return Future(callback=lambda: self.Stat(path)) 159 return Future(callback=lambda: self.Stat(path))
160 160
161 def GetIdentity(self): 161 def GetIdentity(self):
162 '''The identity of the file system, exposed for caching classes to 162 '''The identity of the file system, exposed for caching classes to
163 namespace their caches. this will usually depend on the configuration of 163 namespace their caches. This will usually depend on the configuration of
164 that file system - e.g. a LocalFileSystem with a base path of /var is 164 that file system - e.g. a LocalFileSystem with a base path of /var is
165 different to that of a SubversionFileSystem with a base path of /bar, is 165 different to that of a SubversionFileSystem with a base path of /bar, is
166 different to a LocalFileSystem with a base path of /usr. 166 different to a LocalFileSystem with a base path of /usr.
167 ''' 167 '''
168 raise NotImplementedError(self.__class__) 168 raise NotImplementedError(self.__class__)
169 169
170 def GetVersion(self):
171 '''The version of the file system, exposed for more granular caching.
172 This may be any serializable data, though generally it should be a revision
173 number or hash string. The default implementation returns None, indicating
174 that the FileSystem is not versioned.
175 '''
176 return None
177
170 def Walk(self, root, depth=-1, file_lister=None): 178 def Walk(self, root, depth=-1, file_lister=None):
171 '''Recursively walk the directories in a file system, starting with root. 179 '''Recursively walk the directories in a file system, starting with root.
172 180
173 Behaviour is very similar to os.walk from the standard os module, yielding 181 Behaviour is very similar to os.walk from the standard os module, yielding
174 (base, dirs, files) recursively, where |base| is the base path of |files|, 182 (base, dirs, files) recursively, where |base| is the base path of |files|,
175 |dirs| relative to |root|, and |files| and |dirs| the list of files/dirs in 183 |dirs| relative to |root|, and |files| and |dirs| the list of files/dirs in
176 |base| respectively. If |depth| is specified and greater than 0, Walk will 184 |base| respectively. If |depth| is specified and greater than 0, Walk will
177 only recurse |depth| times. 185 only recurse |depth| times.
178 186
179 |file_lister|, if specified, should be a callback of signature 187 |file_lister|, if specified, should be a callback of signature
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 self.GetIdentity() == other.GetIdentity()) 230 self.GetIdentity() == other.GetIdentity())
223 231
224 def __ne__(self, other): 232 def __ne__(self, other):
225 return not (self == other) 233 return not (self == other)
226 234
227 def __repr__(self): 235 def __repr__(self):
228 return '<%s>' % type(self).__name__ 236 return '<%s>' % type(self).__name__
229 237
230 def __str__(self): 238 def __str__(self):
231 return repr(self) 239 return repr(self)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698