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): |