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

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

Issue 429723005: Docserver: Only fetch content versions in the crons, not their contents. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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
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 posixpath 5 import posixpath
6 from urlparse import urlsplit 6 from urlparse import urlsplit
7 7
8 from file_system import FileNotFoundError 8 from file_system import FileNotFoundError
9 from future import Future 9 from future import All
10 from path_util import Segment, Join, SplitParent 10 from path_util import Segment, Join, SplitParent
11 11
12 class Redirector(object): 12 class Redirector(object):
13 def __init__(self, compiled_fs_factory, file_system): 13 def __init__(self, compiled_fs_factory, file_system):
14 self._file_system = file_system 14 self._file_system = file_system
15 self._cache = compiled_fs_factory.ForJson(file_system) 15 self._cache = compiled_fs_factory.ForJson(file_system)
16 16
17 def Redirect(self, host, path): 17 def Redirect(self, host, path):
18 ''' Check if a path should be redirected, first according to host 18 ''' Check if a path should be redirected, first according to host
19 redirection rules, then from rules in redirects.json files. 19 redirection rules, then from rules in redirects.json files.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 path.pop(0) 101 path.pop(0)
102 102
103 return 'https://developer.chrome.com/' + posixpath.join(*path) 103 return 'https://developer.chrome.com/' + posixpath.join(*path)
104 104
105 def Cron(self): 105 def Cron(self):
106 ''' Load files during a cron run. 106 ''' Load files during a cron run.
107 ''' 107 '''
108 futures = [] 108 futures = []
109 for root, dirs, files in self._file_system.Walk(''): 109 for root, dirs, files in self._file_system.Walk(''):
110 if 'redirects.json' in files: 110 if 'redirects.json' in files:
111 futures.append( 111 futures.append(self._cache.GetFromFile(Join(root, 'redirects.json')))
112 self._cache.GetFromFile(posixpath.join(root, 'redirects.json'))) 112 return All(futures)
113 return Future(callback=lambda: [f.Get() for f in futures])
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/cron.yaml ('k') | chrome/common/extensions/docs/server2/template_data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698