[Git][security-tracker-team/security-tracker][master] 2 commits: Fix check for whether /tracker/data/json needs to be recomputed

Salvatore Bonaccorso carnil at debian.org
Fri Jul 6 23:50:06 BST 2018


Salvatore Bonaccorso pushed to branch master at Debian Security Tracker / security-tracker


Commits:
0186cfff by Julien Cristau at 2018-07-06T23:56:42+02:00
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).

- - - - -
b8cb9452 by Salvatore Bonaccorso at 2018-07-07T00:49:53+02:00
Merge branch 'jcristau/security-tracker-fix-json-last-modified'

- - - - -


1 changed file:

- bin/tracker_service.py


Changes:

=====================================
bin/tracker_service.py
=====================================
--- 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):



View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/compare/470c60f5f84f359783763e9a2aaa13b77f2ebacd...b8cb9452cc10d61e2cee45173f4ca50ed0d8da49

-- 
View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/compare/470c60f5f84f359783763e9a2aaa13b77f2ebacd...b8cb9452cc10d61e2cee45173f4ca50ed0d8da49
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-security-tracker-commits/attachments/20180706/30d102a9/attachment-0001.html>


More information about the debian-security-tracker-commits mailing list