summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2018-11-25 17:48:11 -0800
committerMicah Lee <micah@micahflee.com>2018-11-25 17:48:11 -0800
commit33bd7b4a80738e50dbb810086120635db18876e2 (patch)
tree7a38daf69f6d11826d0dd2572554696cd089b662
parent250dbf91993a4a90a19c33cbff88520ac8660753 (diff)
downloadonionshare-33bd7b4a80738e50dbb810086120635db18876e2.tar.gz
onionshare-33bd7b4a80738e50dbb810086120635db18876e2.zip
Build downloads_dir a different way in macOS, so it's correct despite the sandbox
-rw-r--r--onionshare/settings.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/onionshare/settings.py b/onionshare/settings.py
index 41fcc536..ca3fccfa 100644
--- a/onionshare/settings.py
+++ b/onionshare/settings.py
@@ -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):
"""