[Pkg-privacy-commits] [onionshare] 03/12: Make hidserv_dir a class variable so it can be cleaned up (fixes #232), and refactor _hsdic2list (#199)

Ulrike Uhlig u-guest at moszumanska.debian.org
Mon Jan 4 17:08:38 UTC 2016


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to branch debian
in repository onionshare.

commit 2ce32e23272bf88d8fb73ea62166fe3b5db7b13a
Author: Micah Lee <micah at micahflee.com>
Date:   Sun Dec 6 13:51:42 2015 -0800

    Make hidserv_dir a class variable so it can be cleaned up (fixes #232), and refactor _hsdic2list (#199)
---
 onionshare/hs.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/onionshare/hs.py b/onionshare/hs.py
index 27712b4..3428bfe 100644
--- a/onionshare/hs.py
+++ b/onionshare/hs.py
@@ -107,26 +107,26 @@ class HS(object):
             if not os.access(path, os.W_OK):
                 raise HSDirError(strings._("error_hs_dir_not_writable").format(path))
 
-            hidserv_dir = tempfile.mkdtemp(dir=path)
-            self.cleanup_filenames.append(hidserv_dir)
+            self.hidserv_dir = tempfile.mkdtemp(dir=path)
+            self.cleanup_filenames.append(self.hidserv_dir)
 
             # set up hidden service
             hsdic = self.c.get_conf_map('HiddenServiceOptions') or {
                 'HiddenServiceDir': [], 'HiddenServicePort': []
             }
-            if hidserv_dir in hsdic.get('HiddenServiceDir', []):
+            if self.hidserv_dir in hsdic.get('HiddenServiceDir', []):
                 # Maybe a stale service with the wrong local port
-                dropme = hsdic['HiddenServiceDir'].index(hidserv_dir)
+                dropme = hsdic['HiddenServiceDir'].index(self.hidserv_dir)
                 del hsdic['HiddenServiceDir'][dropme]
                 del hsdic['HiddenServicePort'][dropme]
-            hsdic['HiddenServiceDir'] = hsdic.get('HiddenServiceDir', [])+[hidserv_dir]
+            hsdic['HiddenServiceDir'] = hsdic.get('HiddenServiceDir', [])+[self.hidserv_dir]
             hsdic['HiddenServicePort'] = hsdic.get('HiddenServicePort', [])+[
                 '80 127.0.0.1:{0:d}'.format(port)]
 
             self.c.set_options(self._hsdic2list(hsdic))
 
             # figure out the .onion hostname
-            hostname_file = '{0:s}/hostname'.format(hidserv_dir)
+            hostname_file = '{0:s}/hostname'.format(self.hidserv_dir)
             onion_host = open(hostname_file, 'r').read().strip()
             return onion_host
 
@@ -243,7 +243,7 @@ class HS(object):
         ]
         """
         l = []
-        for i in range(len(dic['HiddenServiceDir'])):
-            l.append(('HiddenServiceDir', dic['HiddenServiceDir'][i]))
-            l.append(('HiddenServicePort', dic['HiddenServicePort'][i]))
+        for dir, port in zip(dic['HiddenServiceDir'], dic['HiddenServicePort']):
+            l.append(('HiddenServiceDir', dir))
+            l.append(('HiddenServicePort', port))
         return l

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list