Build downloads_dir a different way in macOS, so it's correct despite the sandbox

This commit is contained in:
Micah Lee 2018-11-25 17:48:11 -08:00
parent 250dbf9199
commit 33bd7b4a80
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73

View File

@ -22,6 +22,7 @@ import json
import os
import platform
import locale
import pwd
from . import strings
@ -128,7 +129,13 @@ class Settings(object):
"""
# TODO: Test in Windows, though it looks like it should work
# https://docs.python.org/3/library/os.path.html#os.path.expanduser
return os.path.expanduser('~/OnionShare')
if self.common.platform == "Darwin":
# We can't use os.path.expanduser in macOS because in the sandbox it
# returns the path to the sandboxed homedir
real_homedir = pwd.getpwuid(os.getuid()).pw_dir
return os.path.join(real_homedir, 'OnionShare')
else:
return os.path.expanduser('~/OnionShare')
def load(self):
"""