Use os.path.expanduser when creating data dir, and no need to try creating data dir in Settings.save because it's created in Config.build_data_dir

This commit is contained in:
Micah Lee 2018-12-21 10:46:09 -08:00
parent 415c01e00a
commit 5d7449c476
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 3 additions and 4 deletions

View File

@ -134,11 +134,11 @@ class Common(object):
except:
# If for some reason we don't have the 'APPDATA' environment variable
# (like running tests in Linux while pretending to be in Windows)
onionshare_data_dir = '~/.config/onionshare'
onionshare_data_dir = os.path.expanduser('~/.config/onionshare')
elif self.platform == 'Darwin':
onionshare_data_dir = '~/Library/Application Support/OnionShare'
onionshare_data_dir = os.path.expanduser('~/Library/Application Support/OnionShare')
else:
onionshare_data_dir = '~/.config/onionshare'
onionshare_data_dir = os.path.expanduser('~/.config/onionshare')
os.makedirs(onionshare_data_dir, 0o700, True)
return onionshare_data_dir

View File

@ -185,7 +185,6 @@ class Settings(object):
Save settings to file.
"""
self.common.log('Settings', 'save')
os.makedirs(os.path.dirname(self.filename), exist_ok=True)
open(self.filename, 'w').write(json.dumps(self._settings))
self.common.log('Settings', 'save', 'Settings saved in {}'.format(self.filename))