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

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

Issue 165353004: Docserver: Fix invalid path usage in CloudStorageFileSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
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
11 from file_system import FileNotFoundError 11 from file_system import FileNotFoundError
12 from future import Gettable, Future 12 from future import Gettable, Future
13 from path_canonicalizer import PathCanonicalizer 13 from path_canonicalizer import PathCanonicalizer
14 from path_util import AssertIsValid, ToDirectory 14 from path_util import AssertIsValid, Join, ToDirectory
15 from special_paths import SITE_VERIFICATION_FILE 15 from special_paths import SITE_VERIFICATION_FILE
16 from third_party.handlebar import Handlebar 16 from third_party.handlebar import Handlebar
17 from third_party.markdown import markdown 17 from third_party.markdown import markdown
18 18
19 19
20 _MIMETYPE_OVERRIDES = { 20 _MIMETYPE_OVERRIDES = {
21 # SVG is not supported by mimetypes.guess_type on AppEngine. 21 # SVG is not supported by mimetypes.guess_type on AppEngine.
22 '.svg': 'image/svg+xml', 22 '.svg': 'image/svg+xml',
23 } 23 }
24 24
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = [self._path_canonicalizer.Cron()] 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(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(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)
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/app.yaml ('k') | chrome/common/extensions/docs/server2/cron.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698