diff options
author | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 20:06:28 +0000 |
---|---|---|
committer | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 20:06:28 +0000 |
commit | eeca53726d1b3ad880bd8bac552a11f52ea3fc47 (patch) | |
tree | 1284df65939120d1c65ad3abad7f04d3738bcfc0 | |
parent | 36e26024450747430fb05285e0b01b1c6a4b6e0b (diff) | |
download | chromium_src-eeca53726d1b3ad880bd8bac552a11f52ea3fc47.zip chromium_src-eeca53726d1b3ad880bd8bac552a11f52ea3fc47.tar.gz chromium_src-eeca53726d1b3ad880bd8bac552a11f52ea3fc47.tar.bz2 |
Devsite server: make images render again.
Review URL: https://codereview.chromium.org/12263041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182520 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 12 insertions, 7 deletions
diff --git a/chrome/common/extensions/docs/server2/compiled_file_system.py b/chrome/common/extensions/docs/server2/compiled_file_system.py index 49adc17..6c547ba 100644 --- a/chrome/common/extensions/docs/server2/compiled_file_system.py +++ b/chrome/common/extensions/docs/server2/compiled_file_system.py @@ -81,8 +81,11 @@ class CompiledFileSystem(object): all_files.extend(self._RecursiveList([dir_ + f for f in files])) return all_files - def GetFromFile(self, path): - """Calls |populate_function| on the contents of the file at |path|. + def GetFromFile(self, path, binary=False): + """Calls |populate_function| on the contents of the file at |path|. If + |binary| is True then the file will be read as binary - but this will only + apply for the first time the file is fetched; if already cached, |binary| + will be ignored. """ version = self._file_system.Stat(path).version cache_entry = self._object_store.Get(self._MakeKey(path), @@ -90,8 +93,9 @@ class CompiledFileSystem(object): time=0).Get() if (cache_entry is not None) and (version == cache_entry.version): return cache_entry._cache_data - cache_data = self._populate_function(path, - self._file_system.ReadSingle(path)) + cache_data = self._populate_function( + path, + self._file_system.ReadSingle(path, binary=binary)) self._object_store.Set(self._MakeKey(path), _CacheEntry(cache_data, version), object_store.FILE_SYSTEM_CACHE, diff --git a/chrome/common/extensions/docs/server2/file_system.py b/chrome/common/extensions/docs/server2/file_system.py index cbc19b31..0c1311c 100644 --- a/chrome/common/extensions/docs/server2/file_system.py +++ b/chrome/common/extensions/docs/server2/file_system.py @@ -36,10 +36,10 @@ class FileSystem(object): """ raise NotImplementedError() - def ReadSingle(self, path): + def ReadSingle(self, path, binary=False): """Reads a single file from the FileSystem. """ - return self.Read([path]).Get()[path] + return self.Read([path], binary=binary).Get()[path] # TODO(cduvall): Allow Stat to take a list of paths like Read. def Stat(self, path): diff --git a/chrome/common/extensions/docs/server2/server_instance.py b/chrome/common/extensions/docs/server2/server_instance.py index 9f4394c..6de063a 100644 --- a/chrome/common/extensions/docs/server2/server_instance.py +++ b/chrome/common/extensions/docs/server2/server_instance.py @@ -29,7 +29,8 @@ class ServerInstance(object): """Fetch a resource in the 'static' directory. """ try: - result = self._cache.GetFromFile(STATIC_DIR_PREFIX + '/' + path) + result = self._cache.GetFromFile(STATIC_DIR_PREFIX + '/' + path, + binary='/images/' in path) except FileNotFoundError: return None base, ext = os.path.splitext(path) |