[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Refactor dropping uncacheable GETCONF params into _set_cache()



commit 9e517998c59a437e7050ebfb685066d249abb21e
Author: Dave Rolek <dmr-x@xxxxxxxxxx>
Date:   Mon May 14 04:14:19 2018 +0000

    Refactor dropping uncacheable GETCONF params into _set_cache()
    
    This likely also fixes a bug where _set_cache() was called without
    dropping these first.
    
    See #25821
---
 stem/control.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index c045eba4..c2467a53 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -2229,10 +2229,6 @@ class Controller(BaseController):
       if self.is_caching_enabled():
         to_cache = dict((k.lower(), v) for k, v in response.entries.items())
 
-        for key in UNCACHEABLE_GETCONF_PARAMS:
-          if key in to_cache:
-            del to_cache[key]
-
         self._set_cache(to_cache, 'getconf')
 
       # Maps the entries back to the parameters that the user requested so the
@@ -3190,6 +3186,14 @@ class Controller(BaseController):
 
         return
 
+      # remove uncacheable items
+      if namespace == 'getconf':
+        # shallow copy before edit so as not to change it for the caller
+        params = params.copy()
+        for key in UNCACHEABLE_GETCONF_PARAMS:
+          if key in params:
+            del params[key]
+
       for key, value in list(params.items()):
         if namespace:
           cache_key = '%s.%s' % (namespace, key)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits