Chromium Code Reviews| Index: gae/main.py |
| diff --git a/gae/main.py b/gae/main.py |
| index e9b427ccf4b140f629772d83337307455d4dc3c1..984d7530150e39e984adfa4e3e72d5786e0835cd 100644 |
| --- a/gae/main.py |
| +++ b/gae/main.py |
| @@ -23,11 +23,32 @@ class MainPage(webapp2.RequestHandler): |
| self.response.write(str(current_config)) |
| class Server(webapp2.RequestHandler): |
| + def get_file_hash(self, meta_content, path): |
|
mnaganov (inactive)
2015/02/24 14:40:32
We should probably cache '(tag, path) -> hash' som
dgozman
2015/02/25 11:37:13
Done.
|
| + for line in meta_content.split('\n'): |
| + index = line.find(':') |
| + if index != -1 and line[(index + 1):] == path: |
| + return line[:index] |
| + return None |
| + |
| def get(self, tag_type, tag, path): |
| cache_key_name = '/res/%s/%s/%s' % (tag_type, tag, path) |
| content = cache.get_content(cache_key_name) |
| helper = config.ConfigHelper(current_config) |
| + if not content and tag_type == 'file': |
|
mnaganov (inactive)
2015/02/24 14:40:32
No, we shouldn't cache these resources under 'cach
dgozman
2015/02/25 11:37:13
Done.
|
| + meta_file_name = helper.get_meta_path(tag) |
| + meta_content = file_reader.read(helper, meta_file_name) |
| + if not meta_content: |
| + self.abort(404) |
| + file_hash = self.get_file_hash(meta_content, path) |
| + if not file_hash: |
| + self.abort(404) |
| + content = file_reader.read(helper, helper.get_hash_path(file_hash)) |
| + if not content: |
| + self.abort(404) |
| + content = content_processor.process(path, content) |
| + cache.set_content(cache_key_name, content) |
| + |
| if not content: |
| if tag_type == 'rev': |
| meta_file_name = helper.get_revision_path(tag) |