summaryrefslogtreecommitdiffstats
path: root/bin/tracker_service.py
diff options
context:
space:
mode:
authorJulien Cristau <jcristau@debian.org>2018-07-06 23:56:42 +0200
committerJulien Cristau <jcristau@debian.org>2018-07-06 23:56:42 +0200
commit0186cfff4f17501c4dcff0c84d8a79cbdb6891c4 (patch)
tree342574118b7f2ddde3d951e7746d7d6991bb2773 /bin/tracker_service.py
parent8a51bec9f458270ee21d501555213527df284403 (diff)
Fix check for whether /tracker/data/json needs to be recomputed
In commit 49e287d2574ed385e31ce3d36cb3cb19f4c7785f "tracker_service: send a Last-Modified header for /tracker/data/json" I made the json_timestamp update conditional on whether the data had changed. That meant that after a few minutes, we would consider the data to be always stale, and recompute it every single time, as long as it didn't change. To fix this, use separate timestamps for "when did we check last" (json_timestamp) and "when did it change last" (json_last_modified).
Diffstat (limited to 'bin/tracker_service.py')
-rwxr-xr-xbin/tracker_service.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/tracker_service.py b/bin/tracker_service.py
index 6dda2d48d0..38e01022ae 100755
--- a/bin/tracker_service.py
+++ b/bin/tracker_service.py
@@ -137,6 +137,7 @@ class TrackerService(webservice_base_class):
self.db = security_db.DB(db_name)
self.json_data = None # the JSON dump itself
self.json_timestamp = None # timestamp of JSON generation
+ self.json_last_modified = None
self.register('', self.page_home)
self.register('*', self.page_object)
self.register('redirect/*', self.page_redirect)
@@ -1452,14 +1453,15 @@ Debian bug number.'''),
# store the JSON dump in memory, and update the generation
# timestamp before returning
new_data = json.dumps(data, separators=(',', ':'))
+ self.json_timestamp = time.time()
if new_data != self.json_data:
self.json_data = new_data
- self.json_timestamp = time.time()
+ self.json_last_modified = self.json_timestamp
return self.json_data
def page_json(self, path, params, url):
result = BinaryResult(self._get_json(),'application/json')
- result.headers['Last-Modified'] = email.utils.formatdate(self.json_timestamp, usegmt=True)
+ result.headers['Last-Modified'] = email.utils.formatdate(self.json_last_modified, usegmt=True)
return result
def page_debsecan(self, path, params, url):

© 2014-2024 Faster IT GmbH | imprint | privacy policy