Add downloads_dir to settings, make it default to ~/Downloads

This commit is contained in:
Micah Lee 2018-03-05 07:52:51 -08:00
parent 18ac830a9e
commit 383ccb94fc
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 11 additions and 2 deletions

View File

@ -86,6 +86,7 @@ def main(cwd=None):
settings = Settings(config)
settings.load()
# Start the Onion object
onion = Onion()
@ -122,7 +123,6 @@ def main(cwd=None):
print('')
# Start OnionShare http service in new thread
settings.load()
t = threading.Thread(target=web.start, args=(app.port, app.stay_open, settings.get('slug')))
t.daemon = True
t.start()

View File

@ -70,7 +70,8 @@ class Settings(object):
'save_private_key': False,
'private_key': '',
'slug': '',
'hidservauth_string': ''
'hidservauth_string': '',
'downloads_dir': self.build_default_downloads_dir()
}
self._settings = {}
self.fill_in_defaults()
@ -97,6 +98,14 @@ class Settings(object):
else:
return os.path.expanduser('~/.config/onionshare/onionshare.json')
def build_default_downloads_dir(self):
"""
Returns the path of the default Downloads directory for receive mode.
"""
# 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('~/Downloads')
def load(self):
"""
Load the settings from file.