| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 mimetypes | 5 import mimetypes |
| 6 import posixpath | 6 import posixpath |
| 7 import traceback | 7 import traceback |
| 8 | 8 |
| 9 from compiled_file_system import SingleFile | 9 from compiled_file_system import SingleFile |
| 10 from directory_zipper import DirectoryZipper | 10 from directory_zipper import DirectoryZipper |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 return (self.file_system.Exists(ToDirectory(path)) | 188 return (self.file_system.Exists(ToDirectory(path)) |
| 189 .Then(get_index_if_directory_exists)) | 189 .Then(get_index_if_directory_exists)) |
| 190 | 190 |
| 191 # Try to find a file with the right name. If not, and it's a directory, | 191 # Try to find a file with the right name. If not, and it's a directory, |
| 192 # look for an index file in that directory. If nothing at all is found, | 192 # look for an index file in that directory. If nothing at all is found, |
| 193 # return the original |path| - its nonexistence will be caught up the stack. | 193 # return the original |path| - its nonexistence will be caught up the stack. |
| 194 return (find_file_with_name(path) | 194 return (find_file_with_name(path) |
| 195 .Then(lambda found: found or find_index_file()) | 195 .Then(lambda found: found or find_index_file()) |
| 196 .Then(lambda found: found or path)) | 196 .Then(lambda found: found or path)) |
| 197 | 197 |
| 198 def Cron(self): | 198 def Refresh(self): |
| 199 futures = [self._path_canonicalizer.Cron()] | 199 futures = [self._path_canonicalizer.Refresh()] |
| 200 for root, _, files in self.file_system.Walk(''): | 200 for root, _, files in self.file_system.Walk(''): |
| 201 for f in files: | 201 for f in files: |
| 202 futures.append(self.GetContentAndType(Join(root, f))) | 202 futures.append(self.GetContentAndType(Join(root, f))) |
| 203 # Also cache the extension-less version of the file if needed. | 203 # Also cache the extension-less version of the file if needed. |
| 204 base, ext = posixpath.splitext(f) | 204 base, ext = posixpath.splitext(f) |
| 205 if f != SITE_VERIFICATION_FILE and ext in self._default_extensions: | 205 if f != SITE_VERIFICATION_FILE and ext in self._default_extensions: |
| 206 futures.append(self.GetContentAndType(Join(root, base))) | 206 futures.append(self.GetContentAndType(Join(root, base))) |
| 207 # TODO(kalman): Cache .zip files for each directory (if supported). | 207 # TODO(kalman): Cache .zip files for each directory (if supported). |
| 208 return All(futures, except_pass=Exception, except_pass_log=True) | 208 return All(futures, except_pass=Exception, except_pass_log=True) |
| 209 | 209 |
| 210 def __repr__(self): | 210 def __repr__(self): |
| 211 return 'ContentProvider of <%s>' % repr(self.file_system) | 211 return 'ContentProvider of <%s>' % repr(self.file_system) |
| OLD | NEW |