Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/compiled_file_system.py |
| diff --git a/chrome/common/extensions/docs/server2/compiled_file_system.py b/chrome/common/extensions/docs/server2/compiled_file_system.py |
| index 6c547ba2a2b9a9efc9f9faffc0692872f80b023a..9c52ebeaf5a2623f8aaea1c131bec35fff58e79b 100644 |
| --- a/chrome/common/extensions/docs/server2/compiled_file_system.py |
| +++ b/chrome/common/extensions/docs/server2/compiled_file_system.py |
| @@ -5,6 +5,7 @@ |
| import os |
| import object_store |
| +import logging |
| APPS = 'Apps' |
| APPS_FS = 'AppsFileSystem' |
| @@ -47,7 +48,8 @@ class CompiledFileSystem(object): |
| """Create a CompiledFileSystem that populates the cache by calling |
| |populate_function| with (path, data), where |data| is the data that was |
| fetched from |path|. The keys to the cache are put in the namespace |
| - specified by |namespace|, and optionally adding |version|. """ |
| + specified by |namespace|, and optionally adding |version|. |
| + """ |
| return CompiledFileSystem(self._file_system, |
| populate_function, |
| self._object_store, |
| @@ -68,7 +70,7 @@ class CompiledFileSystem(object): |
| self._namespace = '%s.%s' % (self._namespace, version) |
| def _MakeKey(self, key): |
| - return self._namespace + '.' + key |
| + return '%s.%s' % (self._namespace, key) |
| def _RecursiveList(self, files): |
| all_files = files[:] |
| @@ -93,14 +95,18 @@ 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, binary=binary)) |
| - self._object_store.Set(self._MakeKey(path), |
| - _CacheEntry(cache_data, version), |
| - object_store.FILE_SYSTEM_CACHE, |
| - time=0) |
| - return cache_data |
| + try: |
| + 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, |
| + time=0) |
| + return cache_data |
| + except ValueError: |
| + logging.error('Could not get data for the file at %s' % path) |
|
cduvall
2013/03/27 23:01:10
..file at %s: %s' % (path, e)
epeterson
2013/03/28 00:53:51
Done.
|
| + return None |
| def GetFromFileListing(self, path): |
| """Calls |populate_function| on the listing of the files at |path|. |