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

[tor-commits] [stem/master] Include *.new files when reading Tor's data directory



commit 9f61d65f56d1cda27ffb949d3801682ec3b2755f
Author: Ossi Herrala <oherrala@xxxxxxxxx>
Date:   Thu Nov 13 15:59:16 2014 +0200

    Include *.new files when reading Tor's data directory
    
    stem.descriptor.parse_file: Support for parsing cached-descriptors.new,
    cached-extrainfo.new and cached-microdescs.new like their counterparts without
    ".new".
---
 docs/change_log.rst         |    1 +
 stem/descriptor/__init__.py |    6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index e11c316..cb6d85e 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -54,6 +54,7 @@ The following are only available within Stem's `git repository
 
   * Improved speed for parsing consensus documents by around 30% (:trac:`12859`)
   * Don't fail if consensus method 1 is not present, as it is no longer required (:spec:`fc8a6f0`)
+  * Include '\*.new' files when reading from a Tor data directory (patch by oherrala, :trac:`13756`)
   * Updated the authorities we list, `replacing turtles with longclaw <https://lists.torproject.org/pipermail/tor-talk/2014-November/035650.html>`_ and `updating gabelmoo's address <https://lists.torproject.org/pipermail/tor-talk/2014-September/034898.html>`_
 
  * **Utilities**
diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index c14d984..e45ce1e 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -197,11 +197,11 @@ def parse_file(descriptor_file, descriptor_type = None, validate = True, documen
   else:
     # Cached descriptor handling. These contain multiple descriptors per file.
 
-    if filename == 'cached-descriptors':
+    if filename == 'cached-descriptors' or filename == 'cached-descriptors.new':
       file_parser = lambda f: stem.descriptor.server_descriptor._parse_file(f, validate = validate, **kwargs)
-    elif filename == 'cached-extrainfo':
+    elif filename == 'cached-extrainfo' or filename == 'cached-extrainfo.new':
       file_parser = lambda f: stem.descriptor.extrainfo_descriptor._parse_file(f, validate = validate, **kwargs)
-    elif filename == 'cached-microdescs':
+    elif filename == 'cached-microdescs' or filename == 'cached-microdescs.new':
       file_parser = lambda f: stem.descriptor.microdescriptor._parse_file(f, validate = validate, **kwargs)
     elif filename == 'cached-consensus':
       file_parser = lambda f: stem.descriptor.networkstatus._parse_file(f, validate = validate, document_handler = document_handler, **kwargs)

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