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 logging | 5 import logging |
6 import posixpath | 6 import posixpath |
7 import sys | 7 import sys |
8 | 8 |
9 from file_system import FileSystem, StatInfo, FileNotFoundError | 9 from file_system import FileSystem, StatInfo, FileNotFoundError |
10 from future import All, Future | 10 from future import All, Future |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 if skip_not_found: | 126 if skip_not_found: |
127 # Filter out paths which we know do not exist, i.e. if |path| is in | 127 # Filter out paths which we know do not exist, i.e. if |path| is in |
128 # |cached_read_values| *and* has a None version, then it doesn't exist. | 128 # |cached_read_values| *and* has a None version, then it doesn't exist. |
129 # See the above declaration of |cached_read_values| for more information. | 129 # See the above declaration of |cached_read_values| for more information. |
130 paths = [path for path in paths | 130 paths = [path for path in paths |
131 if cached_read_values.get(path, (None, True))[1]] | 131 if cached_read_values.get(path, (None, True))[1]] |
132 | 132 |
133 remaining_paths = set(paths) - set(up_to_date_data.iterkeys()) | 133 remaining_paths = set(paths) - set(up_to_date_data.iterkeys()) |
134 if len(remaining_paths) == 0: | 134 if len(remaining_paths) == 0: |
135 # Everything was cached and up-to-date. | 135 # Everything was cached and up to date. |
136 return Future(value=up_to_date_data) | 136 return Future(value=up_to_date_data) |
137 | 137 |
138 def raise_cache_miss(paths): | 138 def raise_cache_miss(paths): |
139 raise FileNotFoundError('Got cache miss when trying to stat %s' % paths) | 139 raise FileNotFoundError('Got cache miss when trying to stat %s' % paths) |
140 | 140 |
141 if self._fail_on_miss: | 141 if self._fail_on_miss: |
142 # Ignore missing values and return anyway. | 142 # Ignore missing values and return anyway. |
143 logging.warn('Read cache miss for %s on %s' % | 143 logging.warn('Read cache miss for %s on %s' % |
144 (remaining_paths, self.GetIdentity())) | 144 (remaining_paths, self.GetIdentity())) |
145 return Future(callback=lambda: raise_cache_miss(remaining_paths)) | 145 return Future(callback=lambda: raise_cache_miss(remaining_paths)) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return self._file_system.Walk(root, depth=depth, file_lister=file_lister) | 190 return self._file_system.Walk(root, depth=depth, file_lister=file_lister) |
191 | 191 |
192 def GetIdentity(self): | 192 def GetIdentity(self): |
193 return self._file_system.GetIdentity() | 193 return self._file_system.GetIdentity() |
194 | 194 |
195 def GetVersion(self): | 195 def GetVersion(self): |
196 return self._file_system.GetVersion() | 196 return self._file_system.GetVersion() |
197 | 197 |
198 def __repr__(self): | 198 def __repr__(self): |
199 return '%s of <%s>' % (type(self).__name__, repr(self._file_system)) | 199 return '%s of <%s>' % (type(self).__name__, repr(self._file_system)) |
OLD | NEW |