[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Fix cache updating logic.
commit 79ed2a50afc489b925bd6eaa78f1342d60877955
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date: Fri Sep 16 17:52:06 2016 +0200
Fix cache updating logic.
* Fix typo in comment
---
ooni/deck/store.py | 11 ++++++++---
ooni/ui/web/server.py | 4 ++--
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/ooni/deck/store.py b/ooni/deck/store.py
index bf1eb7f..f30b0d6 100644
--- a/ooni/deck/store.py
+++ b/ooni/deck/store.py
@@ -92,15 +92,17 @@ class InputStore(object):
yield self.create(country_code)
def _update_cache(self):
+ new_cache = {}
descs = self.path.child("descriptors")
if not descs.exists():
- self._cache = {}
+ self._cache = new_cache
return
for fn in descs.listdir():
with descs.child(fn).open("r") as in_fh:
input_desc = json.load(in_fh)
- self._cache[input_desc.pop("id")] = input_desc
+ new_cache[input_desc.pop("id")] = input_desc
+ self._cache = new_cache
self._cache_stale = False
return
@@ -172,6 +174,7 @@ class DeckStore(object):
deck_enabled_path.remove()
def _update_cache(self):
+ new_cache = {}
for deck_path in self.available_directory.listdir():
if not deck_path.endswith('.yaml'):
continue
@@ -179,7 +182,9 @@ class DeckStore(object):
deck = NGDeck(
deck_path=self.available_directory.child(deck_path).path
)
- self._cache[deck_id] = deck
+ new_cache[deck_id] = deck
+ self._cache = new_cache
+ self._cache_stale = False
def get(self, deck_id):
if self._cache_stale:
diff --git a/ooni/ui/web/server.py b/ooni/ui/web/server.py
index 48f21c7..cee42ce 100644
--- a/ooni/ui/web/server.py
+++ b/ooni/ui/web/server.py
@@ -144,8 +144,8 @@ class LongPoller(object):
class WebUIAPI(object):
app = Klein()
- # Maximum number in seconds after which to return a result even if not
- # change happenned.
+ # Maximum number in seconds after which to return a result even if no
+ # change happened.
_long_polling_timeout = 5
_reactor = reactor
_enable_xsrf_protection = True
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits