Fixed crash in Windows, related to HS directory path and slashes

This commit is contained in:
Micah Lee 2015-12-07 23:47:13 -08:00
parent d67d5010d1
commit e60a82ad22

View File

@ -95,10 +95,11 @@ class HS(object):
else: else:
# come up with a hidden service directory name # come up with a hidden service directory name
if helpers.get_platform() == 'Windows': if helpers.get_platform() == 'Windows':
path = '{0:s}/onionshare'.format(os.environ['Temp'].replace('\\', '/')) self.hidserv_dir = tempfile.mkdtemp()
self.hidserv_dir = self.hidserv_dir.replace('\\', '/')
else: else:
path = '/tmp/onionshare' path = '/tmp/onionshare'
try: try:
if not os.path.exists(path): if not os.path.exists(path):
os.makedirs(path, 0700) os.makedirs(path, 0700)
@ -108,6 +109,7 @@ class HS(object):
raise HSDirError(strings._("error_hs_dir_not_writable").format(path)) raise HSDirError(strings._("error_hs_dir_not_writable").format(path))
self.hidserv_dir = tempfile.mkdtemp(dir=path) self.hidserv_dir = tempfile.mkdtemp(dir=path)
self.cleanup_filenames.append(self.hidserv_dir) self.cleanup_filenames.append(self.hidserv_dir)
# set up hidden service # set up hidden service