[tor-commits] [stem/master] Only provide absolute paths with get_processed_files()

atagar at torproject.org atagar at torproject.org
Mon Mar 26 00:10:01 UTC 2012


commit 0c021dc30ac9b4066e7c647f4a60bfda4511c9c3
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Mar 11 12:54:50 2012 -0700

    Only provide absolute paths with get_processed_files()
    
    The DescriptorReader's targets can be relative paths, and this is fine.
    However, the load and save functions for processed_files expect absolute paths
    so making get_processed_files() expand relative paths.
    
    I'm on the fencepost about if we should do this or make the load/save functions
    accept relative paths. Going with this until someone produces a use case where
    this makes them sad.
---
 stem/descriptor/reader.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/stem/descriptor/reader.py b/stem/descriptor/reader.py
index b003dbd..018adc7 100644
--- a/stem/descriptor/reader.py
+++ b/stem/descriptor/reader.py
@@ -185,11 +185,12 @@ class DescriptorReader(threading.Thread):
     This includes entries set through the set_processed_files() method.
     
     Returns:
-      dict with the paths and unix timestamp for the last modified times of the
-      files we have processed
+      dict with the absolute paths and unix timestamp for the last modified
+      times of the files we have processed
     """
     
-    return dict(self._processed_files)
+    # make sure that we only provide back absolute paths
+    return dict((os.path.abspath(k), v) for (k, v) in self._processed_files.items())
   
   def set_processed_files(self, processed_files):
     """





More information about the tor-commits mailing list