Rename receive mode "downloads_dir" to the OnionShare "data_dir"

This commit is contained in:
Micah Lee 2019-01-20 11:46:20 -08:00
parent 66297303e1
commit 6e3b103ef5
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
7 changed files with 33 additions and 33 deletions

View File

@ -175,7 +175,7 @@ def main(cwd=None):
print('') print('')
if mode == 'receive': if mode == 'receive':
print(strings._('receive_mode_downloads_dir').format(common.settings.get('downloads_dir'))) print(strings._('receive_mode_data_dir').format(common.settings.get('data_dir')))
print('') print('')
print(strings._('receive_mode_warning')) print(strings._('receive_mode_warning'))
print('') print('')

View File

@ -100,7 +100,7 @@ class Settings(object):
'public_mode': False, 'public_mode': False,
'slug': '', 'slug': '',
'hidservauth_string': '', 'hidservauth_string': '',
'downloads_dir': self.build_default_downloads_dir(), 'data_dir': self.build_default_data_dir(),
'locale': None # this gets defined in fill_in_defaults() 'locale': None # this gets defined in fill_in_defaults()
} }
self._settings = {} self._settings = {}
@ -140,7 +140,7 @@ class Settings(object):
""" """
return os.path.join(self.common.build_data_dir(), 'onionshare.json') return os.path.join(self.common.build_data_dir(), 'onionshare.json')
def build_default_downloads_dir(self): def build_default_data_dir(self):
""" """
Returns the path of the default Downloads directory for receive mode. Returns the path of the default Downloads directory for receive mode.
""" """
@ -174,9 +174,9 @@ class Settings(object):
except: except:
pass pass
# Make sure downloads_dir exists # Make sure data_dir exists
try: try:
os.makedirs(self.get('downloads_dir'), exist_ok=True) os.makedirs(self.get('data_dir'), exist_ok=True)
except: except:
pass pass

View File

@ -64,15 +64,15 @@ class ReceiveModeWeb(object):
now = datetime.now() now = datetime.now()
date_dir = now.strftime("%Y-%m-%d") date_dir = now.strftime("%Y-%m-%d")
time_dir = now.strftime("%H.%M.%S") time_dir = now.strftime("%H.%M.%S")
receive_mode_dir = os.path.join(self.common.settings.get('downloads_dir'), date_dir, time_dir) receive_mode_dir = os.path.join(self.common.settings.get('data_dir'), date_dir, time_dir)
valid = True valid = True
try: try:
os.makedirs(receive_mode_dir, 0o700) os.makedirs(receive_mode_dir, 0o700)
except PermissionError: except PermissionError:
self.web.add_request(self.web.REQUEST_ERROR_DOWNLOADS_DIR_CANNOT_CREATE, request.path, { self.web.add_request(self.web.REQUEST_ERROR_DATA_DIR_CANNOT_CREATE, request.path, {
"receive_mode_dir": receive_mode_dir "receive_mode_dir": receive_mode_dir
}) })
print(strings._('error_cannot_create_downloads_dir').format(receive_mode_dir)) print(strings._('error_cannot_create_data_dir').format(receive_mode_dir))
valid = False valid = False
if not valid: if not valid:
flash('Error uploading, please inform the OnionShare user', 'error') flash('Error uploading, please inform the OnionShare user', 'error')

View File

@ -38,7 +38,7 @@ class Web(object):
REQUEST_UPLOAD_FILE_RENAMED = 6 REQUEST_UPLOAD_FILE_RENAMED = 6
REQUEST_UPLOAD_SET_DIR = 7 REQUEST_UPLOAD_SET_DIR = 7
REQUEST_UPLOAD_FINISHED = 8 REQUEST_UPLOAD_FINISHED = 8
REQUEST_ERROR_DOWNLOADS_DIR_CANNOT_CREATE = 9 REQUEST_ERROR_DATA_DIR_CANNOT_CREATE = 9
def __init__(self, common, is_gui, mode='share'): def __init__(self, common, is_gui, mode='share'):
self.common = common self.common = common

View File

@ -393,8 +393,8 @@ class OnionShareGui(QtWidgets.QMainWindow):
elif event["type"] == Web.REQUEST_UPLOAD_FINISHED: elif event["type"] == Web.REQUEST_UPLOAD_FINISHED:
mode.handle_request_upload_finished(event) mode.handle_request_upload_finished(event)
if event["type"] == Web.REQUEST_ERROR_DOWNLOADS_DIR_CANNOT_CREATE: if event["type"] == Web.REQUEST_ERROR_DATA_DIR_CANNOT_CREATE:
Alert(self.common, strings._('error_cannot_create_downloads_dir').format(event["data"]["receive_mode_dir"])) Alert(self.common, strings._('error_cannot_create_data_dir').format(event["data"]["receive_mode_dir"]))
if event["type"] == Web.REQUEST_OTHER: if event["type"] == Web.REQUEST_OTHER:
if event["path"] != '/favicon.ico' and event["path"] != "/{}/shutdown".format(mode.web.shutdown_slug): if event["path"] != '/favicon.ico' and event["path"] != "/{}/shutdown".format(mode.web.shutdown_slug):

View File

@ -187,16 +187,16 @@ class SettingsDialog(QtWidgets.QDialog):
sharing_group = QtWidgets.QGroupBox(strings._("gui_settings_sharing_label")) sharing_group = QtWidgets.QGroupBox(strings._("gui_settings_sharing_label"))
sharing_group.setLayout(sharing_group_layout) sharing_group.setLayout(sharing_group_layout)
# Downloads dir # OnionShare data dir
downloads_label = QtWidgets.QLabel(strings._('gui_settings_downloads_label')); data_dir_label = QtWidgets.QLabel(strings._('gui_settings_data_dir_label'));
self.downloads_dir_lineedit = QtWidgets.QLineEdit() self.data_dir_lineedit = QtWidgets.QLineEdit()
self.downloads_dir_lineedit.setReadOnly(True) self.data_dir_lineedit.setReadOnly(True)
downloads_button = QtWidgets.QPushButton(strings._('gui_settings_downloads_button')) data_dir_button = QtWidgets.QPushButton(strings._('gui_settings_data_dir_browse_button'))
downloads_button.clicked.connect(self.downloads_button_clicked) data_dir_button.clicked.connect(self.data_dir_button_clicked)
downloads_layout = QtWidgets.QHBoxLayout() downloads_layout = QtWidgets.QHBoxLayout()
downloads_layout.addWidget(downloads_label) downloads_layout.addWidget(data_dir_label)
downloads_layout.addWidget(self.downloads_dir_lineedit) downloads_layout.addWidget(self.data_dir_lineedit)
downloads_layout.addWidget(downloads_button) downloads_layout.addWidget(data_dir_button)
# Receiving options layout # Receiving options layout
receiving_group_layout = QtWidgets.QVBoxLayout() receiving_group_layout = QtWidgets.QVBoxLayout()
@ -508,8 +508,8 @@ class SettingsDialog(QtWidgets.QDialog):
if use_legacy_v2_onions or save_private_key: if use_legacy_v2_onions or save_private_key:
self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked) self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked)
downloads_dir = self.old_settings.get('downloads_dir') data_dir = self.old_settings.get('data_dir')
self.downloads_dir_lineedit.setText(downloads_dir) self.data_dir_lineedit.setText(data_dir)
public_mode = self.old_settings.get('public_mode') public_mode = self.old_settings.get('public_mode')
if public_mode: if public_mode:
@ -747,17 +747,17 @@ class SettingsDialog(QtWidgets.QDialog):
if not self.save_private_key_checkbox.isChecked(): if not self.save_private_key_checkbox.isChecked():
self.use_legacy_v2_onions_checkbox.setEnabled(True) self.use_legacy_v2_onions_checkbox.setEnabled(True)
def downloads_button_clicked(self): def data_dir_button_clicked(self):
""" """
Browse for a new downloads directory Browse for a new OnionShare data directory
""" """
downloads_dir = self.downloads_dir_lineedit.text() data_dir = self.data_dir_lineedit.text()
selected_dir = QtWidgets.QFileDialog.getExistingDirectory(self, selected_dir = QtWidgets.QFileDialog.getExistingDirectory(self,
strings._('gui_settings_downloads_label'), downloads_dir) strings._('gui_settings_data_dir_label'), data_dir)
if selected_dir: if selected_dir:
self.common.log('SettingsDialog', 'downloads_button_clicked', 'selected dir: {}'.format(selected_dir)) self.common.log('SettingsDialog', 'data_dir_button_clicked', 'selected dir: {}'.format(selected_dir))
self.downloads_dir_lineedit.setText(selected_dir) self.data_dir_lineedit.setText(selected_dir)
def test_tor_clicked(self): def test_tor_clicked(self):
""" """
@ -981,7 +981,7 @@ class SettingsDialog(QtWidgets.QDialog):
# Also unset the HidServAuth if we are removing our reusable private key # Also unset the HidServAuth if we are removing our reusable private key
settings.set('hidservauth_string', '') settings.set('hidservauth_string', '')
settings.set('downloads_dir', self.downloads_dir_lineedit.text()) settings.set('data_dir', self.data_dir_lineedit.text())
settings.set('public_mode', self.public_mode_checkbox.isChecked()) settings.set('public_mode', self.public_mode_checkbox.isChecked())
settings.set('use_stealth', self.stealth_checkbox.isChecked()) settings.set('use_stealth', self.stealth_checkbox.isChecked())
# Always unset the HidServAuth if Stealth mode is unset # Always unset the HidServAuth if Stealth mode is unset

View File

@ -140,8 +140,8 @@
"gui_file_info_single": "{} file, {}", "gui_file_info_single": "{} file, {}",
"history_in_progress_tooltip": "{} in progress", "history_in_progress_tooltip": "{} in progress",
"history_completed_tooltip": "{} completed", "history_completed_tooltip": "{} completed",
"error_cannot_create_downloads_dir": "Could not create receive mode folder: {}", "error_cannot_create_data_dir": "Could not create OnionShare data folder: {}",
"receive_mode_downloads_dir": "Files sent to you appear in this folder: {}", "receive_mode_data_dir": "Files sent to you appear in this folder: {}",
"receive_mode_warning": "Warning: Receive mode lets people upload files to your computer. Some files can potentially take control of your computer if you open them. Only open things from people you trust, or if you know what you are doing.", "receive_mode_warning": "Warning: Receive mode lets people upload files to your computer. Some files can potentially take control of your computer if you open them. Only open things from people you trust, or if you know what you are doing.",
"gui_receive_mode_warning": "Receive mode lets people upload files to your computer.<br><br><b>Some files can potentially take control of your computer if you open them. Only open things from people you trust, or if you know what you are doing.</b>", "gui_receive_mode_warning": "Receive mode lets people upload files to your computer.<br><br><b>Some files can potentially take control of your computer if you open them. Only open things from people you trust, or if you know what you are doing.</b>",
"receive_mode_upload_starting": "Upload of total size {} is starting", "receive_mode_upload_starting": "Upload of total size {} is starting",
@ -149,8 +149,8 @@
"gui_mode_share_button": "Share Files", "gui_mode_share_button": "Share Files",
"gui_mode_receive_button": "Receive Files", "gui_mode_receive_button": "Receive Files",
"gui_settings_receiving_label": "Receiving settings", "gui_settings_receiving_label": "Receiving settings",
"gui_settings_downloads_label": "Save files to", "gui_settings_data_dir_label": "Save files to",
"gui_settings_downloads_button": "Browse", "gui_settings_data_dir_browse_button": "Browse",
"gui_settings_public_mode_checkbox": "Public mode", "gui_settings_public_mode_checkbox": "Public mode",
"gui_open_folder_error_nautilus": "Cannot open folder because nautilus is not available. The file is here: {}", "gui_open_folder_error_nautilus": "Cannot open folder because nautilus is not available. The file is here: {}",
"gui_settings_language_label": "Preferred language", "gui_settings_language_label": "Preferred language",