Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgweb_mod.py @ 26150:ee31ede3afb8 stable
hgweb: use latest mtime for caching tag (issue4814)
Previously, we were using the last mtime we saw when reporting the
HTTP cache etag. When we added bookmarks to the end of the list of
files checked, unchanged or missing bookmarks would keep the client
cache from being invalidated.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 03 Sep 2015 12:19:43 -0500 |
parents | 1a45e49a6bed |
children | 7187f6e923d5 |
comparison
equal
deleted
inserted
replaced
26122:d0843f7e16b4 | 26150:ee31ede3afb8 |
---|---|
129 else: | 129 else: |
130 return repo.filtered('served') | 130 return repo.filtered('served') |
131 | 131 |
132 def refresh(self, request=None): | 132 def refresh(self, request=None): |
133 repostate = [] | 133 repostate = [] |
134 mtime = 0 | |
134 # file of interrests mtime and size | 135 # file of interrests mtime and size |
135 for meth, fname in foi: | 136 for meth, fname in foi: |
136 prefix = getattr(self.repo, meth) | 137 prefix = getattr(self.repo, meth) |
137 st = get_stat(prefix, fname) | 138 st = get_stat(prefix, fname) |
138 repostate.append((st.st_mtime, st.st_size)) | 139 repostate.append((st.st_mtime, st.st_size)) |
140 mtime = max(mtime, st.st_mtime) | |
139 repostate = tuple(repostate) | 141 repostate = tuple(repostate) |
140 # we need to compare file size in addition to mtime to catch | 142 # we need to compare file size in addition to mtime to catch |
141 # changes made less than a second ago | 143 # changes made less than a second ago |
142 if repostate != self.repostate: | 144 if repostate != self.repostate: |
143 r = hg.repository(self.repo.baseui, self.repo.url()) | 145 r = hg.repository(self.repo.baseui, self.repo.url()) |
151 encoding.encoding = self.config("web", "encoding", | 153 encoding.encoding = self.config("web", "encoding", |
152 encoding.encoding) | 154 encoding.encoding) |
153 # update these last to avoid threads seeing empty settings | 155 # update these last to avoid threads seeing empty settings |
154 self.repostate = repostate | 156 self.repostate = repostate |
155 # mtime is needed for ETag | 157 # mtime is needed for ETag |
156 self.mtime = st.st_mtime | 158 self.mtime = mtime |
157 if request: | 159 if request: |
158 self.repo.ui.environ = request.env | 160 self.repo.ui.environ = request.env |
159 | 161 |
160 def run(self): | 162 def run(self): |
161 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): | 163 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): |