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('')
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(strings._('receive_mode_warning'))
print('')

View file

@ -100,7 +100,7 @@ class Settings(object):
'public_mode': False,
'slug': '',
'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()
}
self._settings = {}
@ -140,7 +140,7 @@ class Settings(object):
"""
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.
"""
@ -174,9 +174,9 @@ class Settings(object):
except:
pass
# Make sure downloads_dir exists
# Make sure data_dir exists
try:
os.makedirs(self.get('downloads_dir'), exist_ok=True)
os.makedirs(self.get('data_dir'), exist_ok=True)
except:
pass

View file

@ -64,15 +64,15 @@ class ReceiveModeWeb(object):
now = datetime.now()
date_dir = now.strftime("%Y-%m-%d")
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
try:
os.makedirs(receive_mode_dir, 0o700)
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
})
print(strings._('error_cannot_create_downloads_dir').format(receive_mode_dir))
print(strings._('error_cannot_create_data_dir').format(receive_mode_dir))
valid = False
if not valid:
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_SET_DIR = 7
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'):
self.common = common

View file

@ -393,8 +393,8 @@ class OnionShareGui(QtWidgets.QMainWindow):
elif event["type"] == Web.REQUEST_UPLOAD_FINISHED:
mode.handle_request_upload_finished(event)
if event["type"] == Web.REQUEST_ERROR_DOWNLOADS_DIR_CANNOT_CREATE:
Alert(self.common, strings._('error_cannot_create_downloads_dir').format(event["data"]["receive_mode_dir"]))
if event["type"] == Web.REQUEST_ERROR_DATA_DIR_CANNOT_CREATE:
Alert(self.common, strings._('error_cannot_create_data_dir').format(event["data"]["receive_mode_dir"]))
if event["type"] == Web.REQUEST_OTHER:
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.setLayout(sharing_group_layout)
# Downloads dir
downloads_label = QtWidgets.QLabel(strings._('gui_settings_downloads_label'));
self.downloads_dir_lineedit = QtWidgets.QLineEdit()
self.downloads_dir_lineedit.setReadOnly(True)
downloads_button = QtWidgets.QPushButton(strings._('gui_settings_downloads_button'))
downloads_button.clicked.connect(self.downloads_button_clicked)
# OnionShare data dir
data_dir_label = QtWidgets.QLabel(strings._('gui_settings_data_dir_label'));
self.data_dir_lineedit = QtWidgets.QLineEdit()
self.data_dir_lineedit.setReadOnly(True)
data_dir_button = QtWidgets.QPushButton(strings._('gui_settings_data_dir_browse_button'))
data_dir_button.clicked.connect(self.data_dir_button_clicked)
downloads_layout = QtWidgets.QHBoxLayout()
downloads_layout.addWidget(downloads_label)
downloads_layout.addWidget(self.downloads_dir_lineedit)
downloads_layout.addWidget(downloads_button)
downloads_layout.addWidget(data_dir_label)
downloads_layout.addWidget(self.data_dir_lineedit)
downloads_layout.addWidget(data_dir_button)
# Receiving options layout
receiving_group_layout = QtWidgets.QVBoxLayout()
@ -508,8 +508,8 @@ class SettingsDialog(QtWidgets.QDialog):
if use_legacy_v2_onions or save_private_key:
self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked)
downloads_dir = self.old_settings.get('downloads_dir')
self.downloads_dir_lineedit.setText(downloads_dir)
data_dir = self.old_settings.get('data_dir')
self.data_dir_lineedit.setText(data_dir)
public_mode = self.old_settings.get('public_mode')
if public_mode:
@ -747,17 +747,17 @@ class SettingsDialog(QtWidgets.QDialog):
if not self.save_private_key_checkbox.isChecked():
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,
strings._('gui_settings_downloads_label'), downloads_dir)
strings._('gui_settings_data_dir_label'), data_dir)
if selected_dir:
self.common.log('SettingsDialog', 'downloads_button_clicked', 'selected dir: {}'.format(selected_dir))
self.downloads_dir_lineedit.setText(selected_dir)
self.common.log('SettingsDialog', 'data_dir_button_clicked', 'selected dir: {}'.format(selected_dir))
self.data_dir_lineedit.setText(selected_dir)
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
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('use_stealth', self.stealth_checkbox.isChecked())
# Always unset the HidServAuth if Stealth mode is unset

View file

@ -140,8 +140,8 @@
"gui_file_info_single": "{} file, {}",
"history_in_progress_tooltip": "{} in progress",
"history_completed_tooltip": "{} completed",
"error_cannot_create_downloads_dir": "Could not create receive mode folder: {}",
"receive_mode_downloads_dir": "Files sent to you appear in this folder: {}",
"error_cannot_create_data_dir": "Could not create OnionShare data 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.",
"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",
@ -149,8 +149,8 @@
"gui_mode_share_button": "Share Files",
"gui_mode_receive_button": "Receive Files",
"gui_settings_receiving_label": "Receiving settings",
"gui_settings_downloads_label": "Save files to",
"gui_settings_downloads_button": "Browse",
"gui_settings_data_dir_label": "Save files to",
"gui_settings_data_dir_browse_button": "Browse",
"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_settings_language_label": "Preferred language",