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

Unified Diff: gae/main.py

Issue 954693002: Store each file as "hash/<sha1>", list of hashes as "meta/@<rev>" and serve them at "serve_file/@<r… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chrome-devtools-frontend
Patch Set: Fixed review comments, added manifest file Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gae/config.py ('k') | gce/uploader_iteration.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gae/main.py
diff --git a/gae/main.py b/gae/main.py
index e9b427ccf4b140f629772d83337307455d4dc3c1..fc02149ae79b639a9dc0eac1f6dce8be4465b696 100644
--- a/gae/main.py
+++ b/gae/main.py
@@ -23,30 +23,64 @@ class MainPage(webapp2.RequestHandler):
self.response.write(str(current_config))
class Server(webapp2.RequestHandler):
- 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)
+ def get_hash_cache_key(self, rev, path):
+ return '/hashes/%s/%s' % (rev, path)
- if not content:
- if tag_type == 'rev':
- meta_file_name = helper.get_revision_path(tag)
- elif tag_type =='ver':
- meta_file_name = helper.get_version_path(tag)
- else:
- self.abort(404)
+ def get_file_hash(self, helper, rev, path):
+ file_hash = cache.get_content(self.get_hash_cache_key(rev, path))
+ if not file_hash:
+ meta_file_name = helper.get_meta_path(rev)
meta_content = file_reader.read(helper, meta_file_name)
- if meta_content:
- zip_file_name = meta_content.strip(' \t\n')
- else:
+ if not meta_content:
self.abort(404)
mnaganov (inactive) 2015/02/25 12:56:35 Let's just return null here to make it clear that
dgozman 2015/02/25 14:22:08 Nice catch! Done.
- content = zip_proxy.read(helper, zip_file_name, path)
+ for line in meta_content.split('\n'):
mnaganov (inactive) 2015/02/25 12:56:35 In case when the path isn't listed in the meta fil
dgozman 2015/02/25 14:22:08 Done.
+ index = line.find(':')
mnaganov (inactive) 2015/02/25 12:56:35 You just do another split here, so you can just wr
dgozman 2015/02/25 14:22:08 Done.
+ if index != -1:
+ line_path = line[(index + 1):]
+ line_hash = line[:index]
+ cache.set_content(self.get_hash_cache_key(rev, line_path), line_hash)
+ if line_path == path:
+ file_hash = line_hash
+
+ return file_hash
+
+ def get(self, tag_type, tag, path):
+ helper = config.ConfigHelper(current_config)
+ content = None
+
+ if tag_type == 'file':
+ file_hash = self.get_file_hash(helper, tag, 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)
+
+ else:
+ cache_key_name = '/res/%s/%s/%s' % (tag_type, tag, path)
+ content = cache.get_content(cache_key_name)
+ if not content:
+ if tag_type == 'rev':
+ meta_file_name = helper.get_revision_path(tag)
+ elif tag_type =='ver':
+ meta_file_name = helper.get_version_path(tag)
+ else:
+ self.abort(404)
+
+ meta_content = file_reader.read(helper, meta_file_name)
+ if meta_content:
+ zip_file_name = meta_content.strip(' \t\n')
+ else:
+ self.abort(404)
+
+ content = zip_proxy.read(helper, zip_file_name, path)
+ if not content:
+ self.abort(404)
+ content = content_processor.process(path, content)
+ cache.set_content(cache_key_name, content)
self.response.headers['Content-Type'] = content_type.from_path(path)
self.response.headers['Access-Control-Allow-Origin'] = '*'
« no previous file with comments | « gae/config.py ('k') | gce/uploader_iteration.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698