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 | 7 |
8 from compiled_file_system import SingleFile | 8 from compiled_file_system import SingleFile |
9 from directory_zipper import DirectoryZipper | 9 from directory_zipper import DirectoryZipper |
10 from docs_server_utils import ToUnicode | 10 from docs_server_utils import ToUnicode |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 # it hardly seems worth the potential performance hit. | 143 # it hardly seems worth the potential performance hit. |
144 if not ext: | 144 if not ext: |
145 for default_ext in self._default_extensions: | 145 for default_ext in self._default_extensions: |
146 if self.file_system.Exists(path + default_ext).Get(): | 146 if self.file_system.Exists(path + default_ext).Get(): |
147 path += default_ext | 147 path += default_ext |
148 break | 148 break |
149 | 149 |
150 return self._content_cache.GetFromFile(path) | 150 return self._content_cache.GetFromFile(path) |
151 | 151 |
152 def Cron(self): | 152 def Cron(self): |
153 futures = [] | 153 futures = [self._path_canonicalizer.Cron()] |
154 for root, _, files in self.file_system.Walk(''): | 154 for root, _, files in self.file_system.Walk(''): |
155 for f in files: | 155 for f in files: |
156 futures.append(self.GetContentAndType(posixpath.join(root, f))) | 156 futures.append(self.GetContentAndType(posixpath.join(root, f))) |
157 # Also cache the extension-less version of the file if needed. | 157 # Also cache the extension-less version of the file if needed. |
158 base, ext = posixpath.splitext(f) | 158 base, ext = posixpath.splitext(f) |
159 if f != SITE_VERIFICATION_FILE and ext in self._default_extensions: | 159 if f != SITE_VERIFICATION_FILE and ext in self._default_extensions: |
160 futures.append(self.GetContentAndType(posixpath.join(root, base))) | 160 futures.append(self.GetContentAndType(posixpath.join(root, base))) |
161 # TODO(kalman): Cache .zip files for each directory (if supported). | 161 # TODO(kalman): Cache .zip files for each directory (if supported). |
162 return Future(delegate=Gettable(lambda: [f.Get() for f in futures])) | 162 return Future(delegate=Gettable(lambda: [f.Get() for f in futures])) |
163 | 163 |
164 def __repr__(self): | 164 def __repr__(self): |
165 return 'ContentProvider of <%s>' % repr(self.file_system) | 165 return 'ContentProvider of <%s>' % repr(self.file_system) |
OLD | NEW |