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

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

Issue 453713002: Docserver: Generate a table of extension/app API owners (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return dir_stat 53 return dir_stat
54 # Was a file stat. Extract that file. 54 # Was a file stat. Extract that file.
55 file_version = dir_stat.child_versions.get(file_path) 55 file_version = dir_stat.child_versions.get(file_path)
56 if file_version is None: 56 if file_version is None:
57 raise FileNotFoundError('No stat found for %s in %s (found %s)' % 57 raise FileNotFoundError('No stat found for %s in %s (found %s)' %
58 (path, dir_path, dir_stat.child_versions)) 58 (path, dir_path, dir_stat.child_versions))
59 return StatInfo(file_version) 59 return StatInfo(file_version)
60 60
61 dir_stat = self._stat_object_store.Get(dir_path).Get() 61 dir_stat = self._stat_object_store.Get(dir_path).Get()
62 if dir_stat is not None: 62 if dir_stat is not None:
63 return Future(value=make_stat_info(dir_stat)) 63 return Future(value=dir_stat).Then(make_stat_info)
ahernandez 2014/08/21 18:07:27 I had to change it to this to avoid FileNotFoundEr
not at google - send to devlin 2014/08/21 21:39:57 Heh, I needed to make that fix as well: https://c
64 64
65 def next(dir_stat): 65 def next(dir_stat):
66 assert dir_stat is not None # should have raised a FileNotFoundError 66 assert dir_stat is not None # should have raised a FileNotFoundError
67 # We only ever need to cache the dir stat. 67 # We only ever need to cache the dir stat.
68 self._stat_object_store.Set(dir_path, dir_stat) 68 self._stat_object_store.Set(dir_path, dir_stat)
69 return make_stat_info(dir_stat) 69 return make_stat_info(dir_stat)
70 return self._MemoizedStatAsyncFromFileSystem(dir_path).Then(next) 70 return self._MemoizedStatAsyncFromFileSystem(dir_path).Then(next)
71 71
72 @memoize 72 @memoize
73 def _MemoizedStatAsyncFromFileSystem(self, dir_path): 73 def _MemoizedStatAsyncFromFileSystem(self, dir_path):
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return new_results 125 return new_results
126 # Read in the values that were uncached or old. 126 # Read in the values that were uncached or old.
127 return self._file_system.Read(set(paths) - set(fresh_data.iterkeys()), 127 return self._file_system.Read(set(paths) - set(fresh_data.iterkeys()),
128 skip_not_found=skip_not_found).Then(next) 128 skip_not_found=skip_not_found).Then(next)
129 129
130 def GetIdentity(self): 130 def GetIdentity(self):
131 return self._file_system.GetIdentity() 131 return self._file_system.GetIdentity()
132 132
133 def __repr__(self): 133 def __repr__(self):
134 return '%s of <%s>' % (type(self).__name__, repr(self._file_system)) 134 return '%s of <%s>' % (type(self).__name__, repr(self._file_system))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698