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

Unified Diff: chrome/common/extensions/docs/server2/content_provider.py

Issue 151773002: Docserver: Properly implement the Cron logic for ContentProvider and TemplateDataSource so that the… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | « chrome/common/extensions/docs/server2/app.yaml ('k') | chrome/common/extensions/docs/server2/cron.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/server2/content_provider.py
diff --git a/chrome/common/extensions/docs/server2/content_provider.py b/chrome/common/extensions/docs/server2/content_provider.py
index 817a280563f8735d81c7bb153e88344d27381f0d..62562985e15088ba22d3b5c23e25f46995a0787e 100644
--- a/chrome/common/extensions/docs/server2/content_provider.py
+++ b/chrome/common/extensions/docs/server2/content_provider.py
@@ -87,18 +87,14 @@ class ContentProvider(object):
return ContentAndType(content, mimetype)
def _MaybeMarkdown(self, path):
- if posixpath.splitext(path)[1] != '.html':
+ base, ext = posixpath.splitext(path)
+ if ext != '.html':
return path
-
- dirname, file_name = posixpath.split(path)
- if dirname != '':
- dirname = dirname + '/'
- file_list = self.file_system.ReadSingle(dirname).Get()
- if file_name in file_list:
+ if self.file_system.Exists(path).Get():
return path
-
- if posixpath.splitext(file_name)[0] + '.md' in file_list:
- return posixpath.splitext(path)[0] + '.md'
+ as_md = base + '.md'
+ if self.file_system.Exists(as_md).Get():
+ return as_md
return path
def GetContentAndType(self, path):
@@ -117,8 +113,11 @@ class ContentProvider(object):
# Running Refresh() on the file system is enough to pull GitHub content,
# which is all we need for now while the full render-every-page cron step
# is in effect.
- # TODO(kalman): Walk over the whole filesystem and compile the content.
- return self.file_system.Refresh()
+ futures = []
+ for root, _, files in self.file_system.Walk(''):
+ futures += [self.GetContentAndType(posixpath.join(root, filename))
+ for filename in files]
+ return Future(delegate=Gettable(lambda: [f.Get() for f in futures]))
def __repr__(self):
return 'ContentProvider of <%s>' % repr(self.file_system)
« no previous file with comments | « chrome/common/extensions/docs/server2/app.yaml ('k') | chrome/common/extensions/docs/server2/cron.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698