Force saving files inside ~/OnionShare if running in flatpak

This commit is contained in:
Micah Lee 2020-06-30 14:27:32 -07:00
parent aa60123cf3
commit 0ae2d7f611
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 8 additions and 2 deletions

View File

@ -24,7 +24,7 @@ from onionshare.web import Web
from ..history import History, ToggleHistory, ReceiveHistoryItem from ..history import History, ToggleHistory, ReceiveHistoryItem
from .. import Mode from .. import Mode
from ....widgets import MinimumWidthWidget from ....widgets import MinimumWidthWidget, Alert
class ReceiveMode(Mode): class ReceiveMode(Mode):
@ -135,6 +135,11 @@ class ReceiveMode(Mode):
) )
if selected_dir: if selected_dir:
# If we're running inside a flatpak package, the data dir must be inside ~/OnionShare
if self.common.gui.is_flatpak:
if not selected_dir.startswith(os.path.expanduser("~/OnionShare")):
Alert(self.common, strings._("gui_receive_flatpak_data_dir"))
self.common.log( self.common.log(
"ReceiveMode", "ReceiveMode",
"data_dir_button_clicked", "data_dir_button_clicked",

View File

@ -22,6 +22,7 @@
"gui_receive_start_server": "Start Receive Mode", "gui_receive_start_server": "Start Receive Mode",
"gui_receive_stop_server": "Stop Receive Mode", "gui_receive_stop_server": "Stop Receive Mode",
"gui_receive_stop_server_autostop_timer": "Stop Receive Mode ({} remaining)", "gui_receive_stop_server_autostop_timer": "Stop Receive Mode ({} remaining)",
"gui_receive_flatpak_data_dir": "Because you installed OnionShare using flatpak, you must save files to a folder in ~/OnionShare.",
"gui_copy_url": "Copy Address", "gui_copy_url": "Copy Address",
"gui_copy_hidservauth": "Copy HidServAuth", "gui_copy_hidservauth": "Copy HidServAuth",
"gui_canceled": "Canceled", "gui_canceled": "Canceled",
@ -209,4 +210,4 @@
"mode_settings_receive_data_dir_label": "Save files to", "mode_settings_receive_data_dir_label": "Save files to",
"mode_settings_receive_data_dir_browse_button": "Browse", "mode_settings_receive_data_dir_browse_button": "Browse",
"mode_settings_website_disable_csp_checkbox": "Disable Content Security Policy header (allows your website to use third-party resources)" "mode_settings_website_disable_csp_checkbox": "Disable Content Security Policy header (allows your website to use third-party resources)"
} }