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

Unified Diff: chrome/common/extensions/docs/server2/template_data_source.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, 4 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/redirector.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/server2/template_data_source.py
diff --git a/chrome/common/extensions/docs/server2/template_data_source.py b/chrome/common/extensions/docs/server2/template_data_source.py
index c7ba8069151f635bf3daa5ba28b6e81d52a2e780..63d26e5f635252172efaf4ab70530e5499f16b4b 100644
--- a/chrome/common/extensions/docs/server2/template_data_source.py
+++ b/chrome/common/extensions/docs/server2/template_data_source.py
@@ -12,7 +12,7 @@ from extensions_paths import (
ARTICLES_TEMPLATES, INTROS_TEMPLATES, PRIVATE_TEMPLATES)
from file_system import FileNotFoundError
from future import All
-from path_util import AssertIsDirectory
+from path_util import AssertIsDirectory, Join
class TemplateDataSource(DataSource):
@@ -35,13 +35,27 @@ class TemplateDataSource(DataSource):
return None
def Cron(self):
- futures = []
- for root, _, files in self._file_system.Walk(self._dir):
- futures += [self._template_cache.GetFromFile(
- posixpath.join(self._dir, root, FormatKey(f)))
- for f in files
- if posixpath.splitext(f)[1] == '.html']
- return All(futures)
+ def map_cron_paths(op):
+ results = []
+ for root, _, files in self._file_system.Walk(self._dir):
+ results += [op(Join(self._dir, root, FormatKey(f)))
+ for f in files
+ if posixpath.splitext(f)[1] == '.html']
+ return results
+
+ # Immediately stat everything so that files are guaranteed to be eventually
+ # up to date. See http://crbug.com/398042 for background.
+ #
+ # XXX: For all: do this asynchronously. Just forget about content. Perhaps
+ # run a second round of Crons that we allow to fail.
+ All(map_cron_paths(self._file_system.StatAsync)).Get()
+
+ # Update content in the future.
+ # XXX don't do this, see comment in APIModels.
+ # XXX: Perhaps there should be a method like CronForPaths, RunCronForPaths,
+ # CachePaths, whatever... on CompiledFileSystem. That way it can implement
+ # this behaviour and I don't have to keep commenting what's going on.
+ return All(map_cron_paths(self._template_cache.GetFromFile))
class ArticleDataSource(TemplateDataSource):
« no previous file with comments | « chrome/common/extensions/docs/server2/redirector.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698